I get a 400 bad request - invalid Url when the length of the request exceeds 320+ characters

后端 未结 2 1965
栀梦
栀梦 2021-02-05 19:13

Not sure what could be the reason. Added the following in Web.config also. maxUrlLength=\"1024\" maxQueryStringLength=\"1024\" requestPathInvalidCharacters=\"\" maxRequestLength

相关标签:
2条回答
  • 2021-02-05 20:00

    Just documenting my experience:

    My issue was the one pointed by @Mark at the question comments:

    "by default the maximum url segment length is 260"

    He suggested to increase this limit in the registry, but I didn't want this kind of trouble. The suggestion by @Vignesh T worked better:

    "Replaced the url segment into a querystring parameter and it worked fine"

    In summary, instead of doing:

    http://path.to.website/very-long-string-goes-here/
    

    I just did:

    http://path.to.website/?key=very-long-string-goes-here
    
    0 讨论(0)
  • 2021-02-05 20:06

    run in powershell

    Set-ItemProperty -Path HKLM:\System\CurrentControlSet\Services\HTTP\Parameters -Name UrlSegmentMaxLength -Value 2000 -Type "Dword"

    then do net stop http and net start http.

    https://blogs.msdn.microsoft.com/amyd/2014/02/06/response-400-bad-request-on-long-url/

    0 讨论(0)
提交回复
热议问题