开发者

Allow CON, reserved keywords in URLs

I need to allow URL's that have some reserved keywords like CON, AUX, NUL etc in the URL Names eg: ..../CON/...

Right now I get a 404 Error and the following exception when I try to go to such an URL:

[HttpException]
   at System.Web.CachedPathData.GetConfigPathData(String configPath)
   at System.Web.HttpContext.GetFilePathData()

This has been fixed for .Net 4 according to other posts on this site Semantic urls with dots in .net , I however cannot upgrade to .Net4 due to开发者_Python百科 other dependencies so need an alternative way of doing this.


According to Microsoft's response to this on connect and MSDN forums, there is no workaround in asp.net other than upgrading to 4.0. You could try using IIS url rewriting, but you still can't actually put COM1 (or whatever) in your routes.

(See also: http://haacked.com/archive/2010/04/29/allowing-reserved-filenames-in-URLs.aspx)


ASP.NET 4 fixes this issue with a new setting. In web.config, simply add <httpRuntime relaxedUrlToFileSystemMapping="true"/> to the system.web node. Here’s a snippet from my web.config.

<configuration>
<system.web>
<httpRuntime relaxedUrlToFileSystemMapping="true"/>
<!-- ... your other settings ... -->
</system.web>
</configuration>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜