5

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?

Sha
  • 2,185
  • 1
  • 36
  • 61

1 Answers1

5

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

Artak
  • 2,819
  • 20
  • 31
  • Thanks for suggestion. I am running this on the Azure platform, so this is not an option. – Sha Jan 09 '15 at 22:59
  • Well, .Net Framework has a limitation of 260 chars, however you may try to add this in the configuration file for your web role: – Artak Jan 10 '15 at 00:25
  • You mean in the web.config? Already did that. Same problem :( – Sha Jan 10 '15 at 01:22
  • ANd the last thing I can think about would be to set the maxurl through RequestLimits tag: http://www.iis.net/configreference/system.webserver/security/requestfiltering/requestlimits – Artak Jan 10 '15 at 18:34
  • did you ever fix this ? – djack109 Jun 29 '17 at 13:38
  • @djack109 - I could not find a solution so I shortened the url with a function instead. – Sha Oct 20 '17 at 23:33