to StackOverflow
to StackOverflow

Reputation: 124794

How to stop IIS Express 10.0 returning 411 LengthRequired

I have a .NET 4.6.1 client application that uses HttpWebRequest to call a WebAPI hosted on IIS. One of the calls is a POST request without a body that does not set the ContentLength header (HttpWebRequest.ContentLength has its default value -1, which indicates the property has not been set and that there is no request data to send).

Recently I repaved my development machine with Windows 10 Version 1909 and reinstalled the latest Visual Studio 2017 15.9.22. Since doing this:

I know that I can (and will eventually) fix this by modifying my client code to set ContentLength = 0.

But the client code is out in the field, and I'd like to fix this server-side if possible, e.g. by configuring IIS Express appropriately.

This looks to me like a breaking change in IIS behavior between IIS 8.5 and IIS Express 10.0.14358.1000, in that the latest IIS Express appears to be more restrictive in refusing to accept a POST without ContentLength header.

Is there a way of configuring IIS Express to behave as it used to? Or some other way of fixing this without modifying client code?

Upvotes: 0

Views: 899

Answers (1)

Jokies Ding
Jokies Ding

Reputation: 3504

If you review the request, you will see that the response is not returned from IIS but http.sys HTTP-API/2.0.

enter image description here

Since there is no registry can fix this, I'm afraid the only way to fix 411 is modify you client code. Otherwise, IIS express can't even accept the request.

https://support.microsoft.com/en-us/help/820129/http-sys-registry-settings-for-windows

Upvotes: 1

Related Questions