ASP.NET MVC Routing vs. Reserved Filenames in Windows

asp.net-mvc, iis, windows

Solution

This has been addressed in ASP.NET 4. http://haacked.com/archive/2010/04/29/allowing-reserved-filenames-in-URLs.aspx

You can apply a setting in web.config that relaxes this restriction.

<configuration>
  <system.web>
    <httpRuntime relaxedUrlToFileSystemMapping="true"/>

    <!-- ... your other settings ... -->
  </system.web>
</configuration>

Hope that helps.

Problem

In our ASP.NET MVC application, we've noticed that we cannot have The Forbidden DOS File Names—`COM1` through `COM9`, `LPT1` through `LPT9`, `CON`, `AUX`, `PRN`, and `NUL`—anywhere in our routes. They inevitably result in IIS telling us the file cannot be found, even when we set routing not to check for the existence of files first. How can we work around this?

Original source

Related problems