Boogier Boogier - 26 days ago 25
ASP.NET (C#) Question

IIS 8.5 400 Bad Request - Invalid URL

I've got request to URL of this kind:
https://xxx/test/%81

This results in 400 Bad Request - Invalid URL

I tried to set in web.config:

<httpRuntime requestValidationMode="2.0" relaxedUrlToFileSystemMapping="true" requestPathInvalidCharacters=""/>


But it does not help.

I also tried to use custom request validator:

<httpRuntime requestValidationType="MyNamespace.CustomRequestValidation"/>


But IIS returns 400 before using custom validator.

What else can I do to make IIS to accept this URL?

Thank you.

Answer

According to https://www.iis.net/learn/troubleshoot/diagnosing-http-errors/troubleshooting-http-400-errors-in-iis the underlying problem of HTTP 400 is that the client has sent a request to IIS that breaks one or more rules that HTTP.sys is enforcing.

Http.sys registry settings for Windows are dercribed here: https://support.microsoft.com/en-us/kb/820129

So, in my case problem was solved by setting these keys in HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\HTTP\Parameters as IIS machines:

AllowRestrictedChars = 1
EnableNonUTF8 = 1

After applying these changes to registry IIS machines have to be restarted

Comments