Boogier Boogier - 1 year ago 313
ASP.NET (C#) Question

IIS 8.5 400 Bad Request - Invalid URL

I've got request to URL of this kind:

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 Source

According to 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:

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download