This article is a mirror article of machine translation, please click here to jump to the original article.

View: 20667|Reply: 0

[ASP.NET] GET request "HTTP Error 400. The request URL is invalid"

[Copy link]
Posted on 7/4/2018 9:53:58 AM | | | |


Seeing this misinformation, the average developer may guess two reasons

1. There are special characters in the link

2. The link length is too long(It seems that the length is not the fault, it is vague, I forgot)

The address of the error image is as follows: http://{host}/SearchService. svc/rest/pic600x320/png/kv3hcxmnCmISVvFKojNBGpkN44MRx71vV4v7Qu7ikclbic2vX5Axnm8RxwhLoWyehsSz4J%C2% A72F6h4eQgvkrbzuKGR6y7sszK1KUY75RqxylZMumapwVQttfllaSPXwoRGEeVexDqjmMZSERPquL3uLZbv6Vxdx52nRDUW90SVVYeqkHZbx2w3T1coqt2v036tfaZ%C2%A72D8GBlPbIVJuhSFU5GA8116z8FkV4%C2% A72kDtsxSXy9XTFIziTToRpbQEkp7497O6q99

Next, we began to investigate the reasons for the errors we could encounter

1. Check the URL, there are no special characters (exclude this reason)

2. The url looks really long at first glance, so let's delete half the length of the parameter and then request it. The result is that it can be successful, and then by constantly adding characters, it is found that the length exceeds 339 and reports this error, and there are no special characters after 339, soWe basically determined that the cause of the error should be that the URL is too long

The next step is to solve the relevant problems

Then there are various Baidu, check the configuration related to modifying the querystring length limit

Then modify the web.config

1. Modify the maxQueryStringLength and maxRequestLength configurations under the httpRuntime node

2. Modify the system.webServer node as follows

Saving and running with anticipation, the errors are still the same, and it seems that there is no use

At this time, I began to wonder, why not, will it not take effect, thinking that there may be many people like me, thinking of the global setting of IIS, will this setting not be overridden, we still use all the set values

Don't guess, just check it out (note that the requestFiltering you check is located under system.webServer, don't look at the wrong node)

If it is off, the value of overrideModeDefault is Deny, which means that our configuration will be based on the specific configuration of our site.

So everything is normal, why is it an error?!

Finally, a revert that was not adopted on stackoverflow caught my attention

linkhttps://stackoverflow.com/questi ... is-invalid-in-iis-7



Roughly speaking, the request has not yet reached IIS and is killed by the operating system.

At this time, I searched for another article on Google, which linked to Microsoft's optical radio technical support

The address is as followshttps://support.microsoft.com/zh ... ettings-for-windows

The gist of the two articles is that we need to modify the registry, and the two articles are probably modified by the following two values of the registry



Next, try it and go to the registry CMD="regedit="HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\HTTP\Parameters

Right-click on the blank area and select the Dword value, as shown in the picture



Create a new name called UrlSegmentMaxLength, set the value to 2048, and click OK



The setting of UrlSegmentMaxCount is the same as above, the value is also Dword 2048, click OK.

The modification can only take effect if the HTTP service is restarted

  • Click Start, type Cmd, and then click OK.
  • At the command prompt, type net stop http and press Enter.
  • At the command prompt, type net start http and press Enter.


Then restart IIS. Try again, ok, no error, perfect solution





Previous:The type "Object" is defined in an unreferenced assembly. Must add a response to the program...
Next:Ionic Development Android App Practice (4): Baidu Map API Positioning
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com