Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

asp.net-mvc

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?

like image 834
dotnetdave82 Avatar asked Apr 24 '12 16:04

dotnetdave82


1 Answers

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

like image 119
Curtis Avatar answered Oct 21 '22 13:10

Curtis