Today the image service is cut to the machine using the CDN, and then a partial picture is reported as error "HTTP error 400. The request URL is invalid "
When you see this error message, there are two reasons why a general developer might guess
1. There are special characters in the link
2. The link length is too long (it seems that the length is too long is not the fault, vague, forgotten)
The address of the error image is as follows: http://{host}/searchservice.svc/rest/pic600x320/png/ kv3hcxmncmisvvfkojnbgpkn44mrx71vv4v7qu7ikclbic2vx5axnm8rxwhlowyehssz4j%c2% A72f6h4eqgvkrbzukgr6y7sszk1kuy75rqxylzmumapwvqttfllaspxworgeevexdqjmmzserpqul3ulzbv6vxdx52nrduw90svvyeqkhzbx2w3t1coqt2v03 6tfaz%c2%a72d8gblpbivjuhsfu5ga8116z8fkv4%c2%a72kdtsxsxy9xtfizittorpbqekp7497o6q99
And then we're going to start with the wrong reasons that we can meet.
1. View URL with no special characters (exclude this reason)
2.url I look really long, then we delete half the length of the parameter request again. The result can be successful, and then through the constant addition of characters, found that the length of more than 339 to report this error, and 339 after there is no special character, so we basically determine the reason for the error is that the URL is too long.
The next step is to solve the problem.
Then there are all kinds of Baidu, to see the relevant modification querystring length limit configuration
Then, modify the Web. config
1. Add maxquerystringlength,maxrequestlength configuration under Modify HttpRuntime node
<requestpathinvalidcharacters= "" requestvalidationmode= "2.0" maxquerystringlength= "2097151" maxurllength= "2097151" maxRequestLength= "2097151" relaxedurltofilesystemmapping= "true" executiontimeout= "36000" delaynotificationtimeout= "36000"/>
2. Modify the system.webserver node as follows
<Security> <requestfilteringallowdoubleescaping= "true"allowhighbitcharacters= "true" > <requestlimitsmaxAllowedContentLength= "2097151"maxquerystring= "2097151"MaxUrl= "2097151" /> </requestfiltering> </Security>
Full of anticipation of preservation, operation, error still, as if there was no egg to use
This time began to wonder, why not, will not take effect, think here may have a lot of people like me, think of the global settings of IIS, will not be able to override this setting, we still use the value of all settings
Don't guess, check it out (note that the requestfiltering is located under System.webserver, do not look at the wrong node)
<name= "requestfiltering" overridemodedefault= "Allow" />
If it is turned off, the value of Overridemodedefault is deny,allow means that our configuration will be subject to the specific configuration of our site.
Then everything is normal ah, why is the error?!
The last stackoverflow of the upper one that has not been adopted has caught my attention.
Link https://stackoverflow.com/questions/8447698/the-request-url-is-invalid-in-iis-7
The general idea is that the request is not yet IIS, and the operating system is getting rid of it.
This time again Google search for another article, linked to Microsoft's light-up technical support
The address is as follows Https://support.microsoft.com/zh-cn/help/820129/http-sys-registry-settings-for-windows
The main idea of the two articles is that we need to modify the registry, a combination of two articles, probably modified is the registry as follows two values
Next try, go to registry CMD = "Regedit="hkey_local_machine\system\currentcontrolset\services\http\parameters
Right-click an empty area, select DWORD Value,
Create a new name Urlsegmentmaxlength, set the value to 2048, then click OK
Urlsegmentmaxcount The settings above, the value is also DWORD 2048, click OK.
Modify complete only restart HTTP service to take effect
- Click Start, tap Run, type CMD, and then click OK.
- At the command prompt, type net stop http, and then press Enter.
- At the command prompt, type net start http, and then press Enter.
Then restart IIS. Try again, OK, no error, perfect solution, in solving the problem too long, the leadership gave a lot of support, the actual situation is not as simple as this article describes the ordinary!
Address the HTTP Error 400 once. The request URL is invalid "error