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?

2
  • it's not "Related", you are posing the link to this same page
    – Toolkit
    May 16, 2019 at 5:08
  • I gave up - it is impossible to send over 260 chars after the /, thanks MS
    – Toolkit
    May 16, 2019 at 5:10

6 Answers 6

85

As per Ashok's answer that would equate to:

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

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

4
  • 1
    Just as an addendum, the maximum possible value is 209715 Mar 7, 2017 at 17:17
  • 4
    The default value is 260.
    – nmit026
    Apr 10, 2017 at 21:44
  • Where do you guys find the documentation to all this? I can't find anything in MSDN and Google only shows old links to .NET Framework 1.1d ocs
    – Leo
    Nov 9, 2018 at 9:28
  • that's not enough, I still get Bad Request - Invalid URL HTTP Error 400. The request URL is invalid. when the string after / is longer than 260
    – Toolkit
    May 16, 2019 at 5:05
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" />
2
  • His post seems to be incorrect - it is "maxRequestLength" not "maxRequestPathLength"
    – Anthony
    Jan 10, 2013 at 22:30
  • @Anthony maxRequestLength also refers to the size of the request payload, which has a default of 4096
    – fusi
    Aug 8, 2016 at 9: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>
....
3

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

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.

3
  • why would you repeat a 2 year old accepted answer almost verbatim?
    – Daniel E.
    May 1, 2014 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. May 2, 2014 at 6: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 Aug 19, 2014 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.