When iis7/7.5 receives a request header that is longer than 16K (the default), a bad request-request Too Long is raised. HTTP Error 400. The size of the request headers is too long. of errors.
Blog Park server has encountered this problem, I wrote a blog post (CNZZ statistical code caused by bad request-request Too Long), the problem is due to the Third-party statistical services CNZZ Statistical code written to a large number of cookies, The request carries these cookies, causing the request header length to exceed the limit.
Originally thought this problem only appears in the Chrome, later has the park friend feedback Firefox also can appear this question. So, to solve this problem, you have to start with the server, and this article is about how to do it from the server side.
Where to begin
According to the IIS Official forum post (HTTP 400. The size of the request headers is too long), the 16K header/Request length limit is the registry (hkey_local_machine\system\currentcontrolset\services\ Http\parameters) is determined by the two parameters MaxFieldLength (Request headers) and MaxRequestBytes (the request header and the request body). So, to start with these two parameters.
Understand the target.
Learn more about MaxRequestBytes and maxfieldlength through Microsoft's official documentation (HTTP://SUPPORT.MICROSOFT.COM/KB/820129):
MaxFieldLength- Sets a upper limit for each header.
Use to set the maximum number of bytes per request header (default 16K).
Maxrequestbytes-determines the upper limit for the "total size" of the Request line and the headers.
Use to set the maximum total number of bytes (default 16K) for the request line (request body) and the request header.
How to strike
The target is to adjust the value of MaxFieldLength and MaxRequestBytes (this assumes that the two values are modified to 32K) and make it effective.
Running regedit, entering Hkey_local_machine\system\currentcontrolset\services\http\parameters,
1. Add the item of type DWORD (32-bit), named MaxFieldLength, value is decimal 32768;
2. Add an item of type DWORD (32-bit), named MaxRequestBytes, with a value of decimal 32768.
Add well, how do you get them into effect? The easiest way is to reboot, but for the server, the last thing you want to do is reboot.
Fortunately, Microsoft's official documentation mentions a solution that does not restart, requiring four commands to be run:
NET stop http
NET start HTTP
net stop iisadmin/y
net start ServiceName
However, the 3rd command net stop iisadmin all IIS-related services, and the 4th command launches all IIS-related services one by one.
Although there is no need to reboot the server, the solution for these four commands I don't like ... There is no better solution on the internet ...
Later, by groping, a simpler approach was found, with just three commands:
NET stop http
NET start HTTP
IISReset
This method has been validated on the server by actual validation.
Summary
One of the pleasures of technology is being able to find the solution that you want in your mind when you encounter a problem, not the solution you want to have in your heart, but when it comes out, you will know it-that's it!
The same is true in life, the person in your mind that you can't accurately describe, and when she or he appears, you will know-that's him/him.