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

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


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


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/