Weird 404 error in ASP.NET MVC when including "con"

asp.net-mvc

Solution

`con` is a reserved word and therefore cannot be put in an MVC route

You need to add the following to your web.config:

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

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

See this article for more information:

Putting the Con (COM1, LPT1, NUL, etc.) Back in your URLs

Problem

I'm going through some of the crawl errors on an MVC application I maintain, and found a 404 error for a URL that looked like it should be valid. The URL is of the format: `/gifts/{categoryName}/{productName}/{productId}/` For some reason, when the productName is set to the value "con" I just get a 404 error. Any other value (different or same length of string) and it seems to work fine. Has anyone ever seen anything like this before?

Original source