asp.net-web-api

Hosting WebAPI using OWIN not working when adding the add the firewall allowed apps

血红的双手。 提交于 2020-04-30 06:33:05
问题 I have a ASP.net web api OWIN based self-host application running Windows Service. I set the base address to `http://hostname.domainName:8099' and this app is running fine for the machine where I am hosting this application. Now from another network machine this url is NOT accessible. The solution I tried is adding an inbound rule for port 8099 and it's working fine. :) Now I came to know on 2nd approach that I can add the executable .exe file to the list of allowed apps in Windows Firewall

ASP.NET MVC Core 3.0 - Why API Request from body keeps returning !ModelState.IsValid?

好久不见. 提交于 2020-04-30 04:43:45
问题 I'm currently using ASP.NET MVC Core 3.0 to create an API project. I was successful to send a POST request without parameter. But currently I'm having a problem when trying to send a POST request with the parameter in JSON via Postman, always getting invalid request as shown below. Notice that there's also key param in the query string to authorize the request using the middleware I created. This part has no problem. Here's the code of the controller: [ApiVersion("1.0")] [Route("api/v{version

Custom middleware with JWT authorization - IsAuthenticated=False

故事扮演 提交于 2020-04-18 07:05:12
问题 I wrote a small middleware code (asp.net core v2.2 + c#) that run AFTER a call to server is executed and run some logic if the user is authenticated. Since it's WebAPI - the authentication is done by using Bearer token. This how the middleware looks like: public class MyMiddleware { private readonly RequestDelegate _next; public MyMiddleware(RequestDelegate next) { _next = next; } public async Task Invoke(HttpContext httpContext) { await _next(httpContext).ConfigureAwait(false); // calling

Custom middleware with JWT authorization - IsAuthenticated=False

谁说我不能喝 提交于 2020-04-18 07:03:48
问题 I wrote a small middleware code (asp.net core v2.2 + c#) that run AFTER a call to server is executed and run some logic if the user is authenticated. Since it's WebAPI - the authentication is done by using Bearer token. This how the middleware looks like: public class MyMiddleware { private readonly RequestDelegate _next; public MyMiddleware(RequestDelegate next) { _next = next; } public async Task Invoke(HttpContext httpContext) { await _next(httpContext).ConfigureAwait(false); // calling

Custom middleware with JWT authorization - IsAuthenticated=False

别说谁变了你拦得住时间么 提交于 2020-04-18 07:03:11
问题 I wrote a small middleware code (asp.net core v2.2 + c#) that run AFTER a call to server is executed and run some logic if the user is authenticated. Since it's WebAPI - the authentication is done by using Bearer token. This how the middleware looks like: public class MyMiddleware { private readonly RequestDelegate _next; public MyMiddleware(RequestDelegate next) { _next = next; } public async Task Invoke(HttpContext httpContext) { await _next(httpContext).ConfigureAwait(false); // calling

ASP.NET WebApi form-urlencoded string deserialize

血红的双手。 提交于 2020-04-16 10:43:31
问题 I develop service with WebApi and Client which send to this service gzipped data by POST method (to save bandwidth). Both of them over my control. On server I receive compressed data, decompress It and have string such as: section[0][caption]=Foo& section[0][address]=175896& section[0][counters][]=2& section[0][counters][]=2& section[0][errors][]=ERR_NOT_AVAILABLE& errors=true& trmtimestamp=1346931864358 ie simple www-form-urlencoded string. Does ASP.NET MVC4 WebApi have some method to bind

Autorest/Swagger generated code for Web Api controller that returns File

 ̄綄美尐妖づ 提交于 2020-04-16 05:10:39
问题 In my ASP.NET Web API application I have a controller like this: [RoutePrefix("api/ratings")] public class RateCostumerController : ApiController { [AllowAnonymous] [Route("Report/GetReport")] [HttpGet] public HttpResponseMessage ExportReport([FromUri] string costumer) { var rd = new ReportDocument(); /*No relevant code here*/ var result = new HttpResponseMessage(HttpStatusCode.OK) { Content = new ByteArrayContent(ms.ToArray()) }; result.Content.Headers.ContentDisposition = new System.Net

How to dynamically create Web APIs (REST apis) in selfhosted owin server?

∥☆過路亽.° 提交于 2020-04-13 08:33:30
问题 I'm looking for a way to dynamically generate web apis and add them at runtime (after selfhosted server has been initialized). Basically the idea would be to: 1. Create a selfhost owin server serving static/already defined controllers (web apis) -> this part is ok At a later time, I want to dynamically generate a new controller and add it somehow to the server so that client can send request to it. -> is there a way to do that? I know I can dynamically build a controller and add it to the

How to send a HTTP POST from Classic ASP with a parameter to a WEB API?

和自甴很熟 提交于 2020-04-11 04:34:08
问题 I am trying to create a call to a WEB API on the same machine on another port. It works fine and sends back the string and hits the .NET breakpoint but the parameter is never being passed..(it is null) .. Is there something I am missing in the classic ASP code to pass that string ? (DataToSend) My calling code: <% Response.Buffer = True Dim xml ' Set xml = Server.CreateObject("Microsoft.XMLHTTP") Set xml = server.Createobject("MSXML2.XMLHTTP") DataToSend="<?xml version=""1.0"" encoding=""UTF

How to send a HTTP POST from Classic ASP with a parameter to a WEB API?

我们两清 提交于 2020-04-11 04:33:49
问题 I am trying to create a call to a WEB API on the same machine on another port. It works fine and sends back the string and hits the .NET breakpoint but the parameter is never being passed..(it is null) .. Is there something I am missing in the classic ASP code to pass that string ? (DataToSend) My calling code: <% Response.Buffer = True Dim xml ' Set xml = Server.CreateObject("Microsoft.XMLHTTP") Set xml = server.Createobject("MSXML2.XMLHTTP") DataToSend="<?xml version=""1.0"" encoding=""UTF