ASP.NET url MAX_PATH limit

2019-01-14 17:35发布

I've found an issue with ASP.NET that I know at least has stumped one other person out there. We were trying to use an HttpModule to handle wildcard requests to a web application. The generated url is dynamic and could potentially be several hundred characters long. Unfortunately there appears to be a limitation in the aspnet_isapi.dll file that limits the length of the path in the url to MAX_PATH which is hardcoded at 260 chars.

Has anyone else ran into this and found a way around this limit? Query string parameters are not an option.

Thanks, Greg Ballard

7条回答
神经病院院长
2楼-- · 2019-01-14 18:38

The registry key UrlSegmentMaxLength can be used to increase the default Windows maximum of 260 characters per Url segment in incoming HTTP requests:

  • Key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\HTTP\Parameters
  • Value: UrlSegmentMaxLength
  • Type: REG_DWORD
  • Data: (Your desired new Url segment maximum allowed length, e.g. 4096)

The maximum allowed value is 32766. If a larger value is specified, it will be ignored. (Credit: Juan Mendes)

More about http.sys settings: http://support.microsoft.com/kb/820129

Restarting the PC is required to make a change to this setting take effect. (Credit: David Rettenbacher, Juan Mendes)

Original source for this answer: https://stackoverflow.com/a/7817739/12484

查看更多
登录 后发表回答