5

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 other dependencies so need an alternative way of doing this.

Community
  • 1
  • 1
taiyo
  • 51
  • 2
  • I'm missing something here. URLs don't have reserved keywords. And I can't find CachedPathData or GetConfigPathData anywhere in MSDN. –  Nov 24 '10 at 06:54
  • @yodaj007 They have special meaning in Windows as they are devices. – Tim Lloyd Nov 24 '10 at 17:22

2 Answers2

3

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)

Philip Rieck
  • 32,368
  • 11
  • 87
  • 99
2

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>
sham
  • 691
  • 8
  • 28
  • See http://haacked.com/archive/2010/04/29/allowing-reserved-filenames-in-URLs.aspx/ – SJC Dec 08 '15 at 09:00
  • I'm running web APIs under .NET 4.7.2 and this does not do anything. The only way I can pass in a user email that has 'con' in it is if I surround the email in quotes i.e. 'con.xx@xxx.com' Any clue how else to derestrict this keyword in 4.7.2? – Ninos Aug 26 '19 at 19:28