maxRequestPathLength not in ASP.NET 4 documentation and doesn't work

自闭症网瘾萝莉.ら 提交于 2019-12-04 17:57:55

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.

Bob Wintemberg

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!