So we have a .Net Core 3.1 Web Api hosted on Service Fabric.
For some requests we use Http Get with a body (yes I know it's not pretty but it's not forbidden) because we want to retrieve some data and so Http Get is the verb to use accoding to REST api.
We made some test and on a "normal" web api without Service Framework it works fine to put a body on a Get Request, but then when we use this on our Api with service fabric we have a
Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException: Reading the request body timed out due to data arriving too slowly. See MinRequestBodyDataRate.
I already try : opt.Limits.MinRequestBodyDataRate = null; in the UseKestrel
When we change the method from Get to Post it's works.
So I was wondering if there was something specials with Service Fabric (maybe with the reverse Proxy) that made our request fail?
Have anyone some clue on what is happening?
Thanks
Related
I have on one side NoPCommerce on the other side our own REST API. I need that NopCommerce to send a post request to our REST API. That part is done.
I want to test this locally, so I started both projects. NopCommerce runs on localhost:5001, our REST API on localhost:7521.
When NopCommerce sends the request, I got an SSL error.
Is there a way to do this?
Thanks
We have 2 Linux Web apps running in Azure ( blessed images, not custom ones) running on .NET 6 with custom domains - one API and an MVC app. It's a multitenant organization and the API is using the host header from the incoming HTTP request to resolve a tenants database. So far so good - on IIS everything is working great - we are setting the host header in the HttpClientFactory with the correct domain name, sending the request and the API does its job.
Now the problem - when deployed to Azure, when we set the header to the domain from which the request should be sent(which is the domain we are currently on), the container goes in to a loop when the first HTTP request occurs, executing this request over and over again and after some time our timeout DelegateHandler on the HttpClient is being hit. If we do not set the header the loop stops but we do not have the correct Host header in the request and our API is unable to process the request.
I know there is a reverse proxy which is resolving which web app should process the request based on the custom domain in Azure and I am pretty sure that's our problem but I am not very familiar with Azure architecture and don't know what to do.
P.S. If we use a custom header and set there the host name and reconfigure the API to use this custom request header everything works fine, but that's not what we want.
So any help would be of great help.
I have a selfhosted WebApi 1 and a costum tracer.
Everything is logged and traced correctly when there are valid requests and responses; however when there is a POST request whose size is larger than the default maxRequestLength the server returns a 400 (Bad Request) to the client and the execution in the pipeline terminates. As the result of this, the tracer will never capture the error.
Looking at the ASP.NET WebApi Message LifeCycle diagram HERE I assume that the 400 response is generated and returned way before the tracer starts its job in the pipeline.
Considering that such error could be easily captured on the Global.asax (On_Error method) what is the solution in capturing errors in a selfhosted WebApi?
Thanks in advance.
I'm assuming you are using Web API 1 self host. Under the covers this is a WCF service host. That MaxRequestLength is a WCF thing.
So, if you want to trap it you will need to drop down to WCF customization and configuration. If you create a configuration class that is derived from HttpSelfHostConfiguration there is an overload that allows you to configure the binding and with a whole lot of WCF magic you probably can capture the error.
My guess is that it is not going to be pretty.
My first suggestion would be to look into the WebAPI 2 Owin HttpListener host. This is not WCF based and you may find it easier to trap these kinds of issues. To be honest I really don't know if the Owin HTTPListener host has a built in equivalent to MaxRequestLength, you may actually have to build it yourself as a MessageHandler.
We need to test a web service which accepts JSON request. Server is implemented with WCF and REST API . Server response is asynchronous. I am thinking of below approach:
Approach 1: Use System.web and call UploadStringAsync
Approach 2: User asynchronous delegates in c#
I need to match response from server with request sent.
Is there any other better way to test REST API.
I need to develop test framework to test web service.
One part of testing a web service is testing what the web service does. You can do that with standard unit testing frameworks. This sort of testing has nothing to do with JSON or HTTP or REST, and that's a good thing. It will ensure that your service will work once you give it the correct JSON or HTTP or REST.
After you have tested the functionality of the service, you may want to write some other tests to make sure that the JSON, HTTP and REST part works. For that, you might use WebRequest or WebClient, or Visual Studio Web Tests.
I've got a client who requires a secure transaction made over HTTPS. They do not provide any web services to consume, so instead they have a simple post over HTTPS with SSL. I have two applications that need to utilize this service, one is a website, one is an iOS app, so I figured to save some time and effort, I would write a proxy web service that both of these applications would use to pass data back and forth between the client's system.
So I have the web service sitting on a server, with an exposed web method which is being consumed by the application. The variables are in the method, can someone please help me with sending that data via https POST to the required URL? I've never done anything like this before and I'm a bit lost. The web service is programmed in C#.
If you are using .NET 4.5, you can use the System.Net.Http.HttpClient
http://msdn.microsoft.com/en-us/library/system.net.http.httpclient.aspx
or, System.Net.HttpWebRequest if you are using older version of the framework.
Here's an example
HttpWebRequest with https in C#