Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

What is so wrong about the string "con"?

OK, my api route configuration is rather uninteresting:

config.Routes.MapHttpRoute(
    name: "DefaultApi",
    routeTemplate: "api/{controller}/{id}",
    defaults: new { id = RouteParameter.Optional }
);

The LocationController has the following method:

public List<LocationViewModel> Get(string id)
{
    return _ds.SearchLocations(id);
}

Everything works as it should, except that I am getting an HTTP 404 error when I try to get the resource like this:

/api/location/con

In this case, the method is not hit. The strange thing is that if I set any other string other than "con" as an id parameter, the controller method is being hit and works correctly!

This is happening while I am debugging my application on localhost with Cassini (same thing with IIS Express). There are no files named "con" in my project directory. After handling app error event, IntelliTrace revealed an HttpException with message: "Failed to map the path '/api/location/con'"...

Any clues? Is this a known bug?

Thanks in advance!

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Certain keywords are not allowed in the URL and CON is one of them. See this. The workaround is to include the following under <system.web> in your Web.config.

<httpRuntime relaxedUrlToFileSystemMapping="true" />
share|improve this answer
    
Ah, apparently some undead zombies are still haunting us... :) Thanks for the great response! –  4n41yz3r Jul 13 '13 at 10:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.