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?
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.
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.
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.
来源:https://stackoverflow.com/questions/3884659/maxrequestpathlength-not-in-asp-net-4-documentation-and-doesnt-work