If I try to use the new maxRequestPathLength settings in an ASP.NET application it does not work. I get an unrecognized attribute error. I've tried using both ASP.NET Integrated and Classic application pools in IIS 7. What is also funny is that if you search for maxRequestPathLength on MSDN it is no where to be found in the documentation except in the list of new features for ASP.NET 4. What gives?
3 Answers
Apparently this setting name was changed and move to the registry under "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\HTTP\Parameters." The name is UrlSegmentMaxLength. The default value is 260. This particular setting limits the amount of characters allowed in each path segment of a URL. In https://stackoverflow.com/questions, "questions" would be a path segment.
Documentation for this can be found in the Microsoft knowledge base article on http.sys registry settings.

- 1
- 1

- 3,212
- 6
- 34
- 44
-
Not sure who down-voted my answer, but it would be nice to know why you did. There's nothing wrong with answering your own question, especially when one puts forth the effort to find one's own answer months after asking the question. – Bob Wintemberg May 25 '11 at 13:54
-
I'm not sure either Bob (it wasn't me, but I also didn't upvote it either). I think my answer is more useful as it doesn't require access to the registry (very rare in shared hosting environment, for example). This is one of those .NET features which seems to have changed a bit since they first published information about it. – Tom Chantler May 27 '11 at 16:37
-
+1 @Bob I am encountering the same issue. Did you find adding a registry entry solved the issue? I'm running IIS 7 and IIS 7. I added the registry DWORD for UrlSegmentMaxLength and it did not have an effect. – Chuck Conway Nov 22 '11 at 23:17
-
@ChuckConway Sorry for the late reply. I didn't see your comment until now. You have to restart IIS completely for it to take effect. If you look at the article at the link posted in my answer it explains how to restart IIS. After doing that the issue should be fixed. – Bob Wintemberg Dec 03 '11 at 18:34
-
@ChuckConway: did you try my answer (above)? This worked for me without needing to access the registry at all. – Tom Chantler Dec 13 '11 at 17:34
-
@Dommer yes, but it did not work. The problem I encountered is each url-segment length exceed the max characters. Your solution is for the entire url, not each segment. – Chuck Conway Dec 13 '11 at 18:22
-
My solution includes `relaxedUrlToFileSystemMapping="true"` which is meant to get round just that problem. Did you try bumping the value up really high? e.g. `
` Apparently you're allowed any integer (so up to 2 billion)... – Tom Chantler Dec 13 '11 at 18:49 -
This works if I do in my localhost. But isn't there an alternative way than doing in registry. Because, I don't have access to change registry on the server where I have hosted. – Firnas Apr 08 '13 at 10:45
I've been struggling with this and with help of this post en several other forum post made it work for me. Here is my log and findings:
To allow longer url's then default, just change this in your web.config (.NET 4.0 and up)
<httpRuntime maxUrlLength="1024" relaxedUrlToFileSystemMapping="true"/>
Note: if relaxedUrlToFileSystemMapping is set te to false, urlsegments larger then 260 wil fail with an IOException PathTooLongException:
The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
To allow longer url segments then the default 260 add/change this registry setting:
"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\HTTP\Parameters." The name is UrlSegmentMaxLength. (Dword)
And most importantly after changing this setting. REBOOT your machine. I've tried IIS-Reset and net stop http / net start http, but this did not make the change effective.
Currently i have 2 machines available. My local dev-machin (Windows 7 / IIS 7.5) and a dev-server (Windows 2003 / IIS 6.0) Both took a reboot to make the changes effective.

- 377
- 1
- 4
- 17
-
Confirmed: registry fix and reboot required, I had an MVC API endpoint that had too plentiful of parameters and this was required for the API documentation page. WebConfig alone worked in IIS express, but not once deployed w/o registry fix. – sobelito Feb 28 '15 at 00:07
This had me foxed for a little while. The way to do this in .NET 4 is like this:
<httpRuntime maxUrlLength="1024" relaxedUrlToFileSystemMapping="true"/>
in the <system.web>
section of the web.config. I did this and it worked.

- 14,753
- 4
- 48
- 53
-
1This only works on local cassini, not default IIS 7 setting. The registry setting needs to be changed on IIS, as shown in the other answers. – Zaid Masud Aug 14 '13 at 11:25