Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

URL length in ASP.NET MVC - 260+ characters gives Bad Request - Invalid URL

I have problems with URLs exceeding 260 characters in

  • ASP.NET MVC 4.0
  • Umbraco CMS
  • Azure Websites

IIS chokes and throws the following error:

Bad Request - Invalid URL

HTTP Error 400. The request URL is invalid.

Example URL:

http://example.com/article/123/some-headline-longer-than-260-characters-with-only-text-and-numbers-used

In my case, the URL is 303 characters long without any querystring. Shortening the URL to 260 chars resolve the problem but for me it is not a viable solution. Since I am using ASP.NET I added the following to web.config - however, the problem remain even with maxUrlLength="1024":

<?xml version="1.0"?>
   <configuration>
      <system.web>
         <httpRuntime 
              requestValidationMode="4.0" 
              requestPathInvalidCharacters="&lt;,&gt;"
              maxUrlLength="1024" 
              maxQueryStringLength="768" 
              relaxedUrlToFileSystemMapping="true" />
      </system.web>
   </configuration>

Additional info: All my URLs are kept below the 2000-ish limit (cf. What is the maximum length of a URL in different browsers?)

Any ideas?

like image 806
Sha Avatar asked Jan 09 '15 22:01

Sha


1 Answers

You may need to extend the limit in the registry: http://support.microsoft.com/kb/820129

like image 134
Artak Avatar answered Oct 17 '22 12:10

Artak