56

I am getting this error:

The length of the URL for this request exceeds the configured maxUrlLength value.

Looking around the closest thing I can find is in the web.config,

<requestFiltering>
   <requestLimits maxUrl="xxx">
</requestFiltering>

However this is not MaxUrlLength nor does it resolve the issue. Any ideas how to fix?

NibblyPig
  • 51,118
  • 72
  • 200
  • 356

6 Answers6

86

As per Ashok's answer that would equate to:

<httpRuntime maxUrlLength="1024" relaxedUrlToFileSystemMapping="true"/>

within <system.web> section of the web.config.

Jesse
  • 8,223
  • 6
  • 49
  • 81
10

Take a look at this post by Hanselman. Although this post is about accepting typically invalid characters in the URL he also mentions how to configure the length of the path and the query string

While we're in here, note that in ASP.NET 4 you can also change allowed path and queryString lengths:

<httpRuntime maxRequestPathLength="260" maxQueryStringLength="2048" />
Matthew Haugen
  • 12,916
  • 5
  • 38
  • 54
Hector Correa
  • 26,290
  • 8
  • 57
  • 73
  • His post seems to be incorrect - it is "maxRequestLength" not "maxRequestPathLength" – Anthony Jan 10 '13 at 22:30
  • @Anthony maxRequestLength also refers to the size of the request payload, which has a default of 4096 – fusi Aug 08 '16 at 09:34
6

I had this problem in a rest service I created using C# .net 4. I set the maxUrlLength variable, in the system.web section, of the Web.Config file.

<?xml version="1.0"?>
<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
    <httpRuntime maxUrlLength="2000"/>
  </system.web>
....
Van
  • 88
  • 1
  • 6
3

have you seen this msdn article that seems to what you need

Ashok Padmanabhan
  • 2,110
  • 1
  • 19
  • 36
0

Having the same problem in IIS8, the solution was to modify the root Web.config for the .NET Framework. This file is located in %windir%\Microsoft.NET\Framework\framework_version\CONFIG. Editing the web.config file in the site root did not resolve the issue.

  • why would you repeat a 2 year old accepted answer almost verbatim? – Daniel E. May 01 '14 at 22:11
  • The point was a perceived difference in IIS8 and explicitly stating which web.config file needed editing. Yes the rest is superfluous. I'll edit this. – user3594326 May 02 '14 at 06:39
  • 1
    I see this same behavior with IIS7. Config setting doesn't seem to have any affect in website web.config, needs to be in .Net Framework web.config. FYI, for long MVC4 api urls, in the website web.config, I also needed to add this system.webServer > requestFiltering > requestLimits > maxUrl / maxQueryString setting you can see here [link](http://stackoverflow.com/questions/12564308/404-errors-when-calling-an-asp-net-mvc-3-controller-with-an-big-url-list/12564863#12564863) – Dudeman3000 Aug 19 '14 at 15:32
0

In my case, I edited the setting visually in the IIS application (Request Filtering area):

request filtering url length

This action modified my web.config as follows:

<security>
  <requestFiltering>
    <requestLimits maxAllowedContentLength="524288000" maxQueryString="4096" />
  </requestFiltering>
</security>

As was mentioned in some of the other answers, be sure to also consider long query strings in the request.

Marcel Gruber
  • 6,668
  • 6
  • 34
  • 60