How to fix ASP.NET HTTP 400 error Bad Request errors
I was working on a system that proxied external contents when I got 400 Bad Request errors for file names with a double period; file..jpg. IIS handled the requests just fine as /dir/file..jpg worked but ASP.NET bombed when I requested /dir/proxy.aspx/file..jpg :
HTTP/1.1 400 Bad Request
Microsoft Knowledge Base article 826437 explains how to fix it:
- Install .NET 1.1 Service Pack 1
- Set the following DWORD registry value: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET VerificationCompatibility = 1
You also get a 400 Bad Request error if the url contains other reserved characters like colon http://server/folder/file.aspx/http://www.anothersite.com/
The syntax /dir/file.apx/something/else/here/123 is useful in many cases. Browsers do not see the url as "dynamic" as it does not contain a question mark so they are more likely to cache the output. The url can also be made shorter, which is important for mobile devices, as it does not have to urlencode all special characters.