ASP.Net MVC 404 errors when route contains an .svc extension

Posted by Kragen on Stack Overflow See other posts from Stack Overflow or by Kragen
Published on 2011-02-18T06:53:11Z Indexed on 2011/02/18 7:25 UTC
Read the original article Hit count: 359

Filed under:
|

I have an ASP.Net MVC 2 site set up under IIS7 using the integrated pipeline with the following route:

routes.MapRoute(
    "MyRoute",
    "mycontroller/{name}/{*path}",
    new { controller = "MyController", action = "Index", path = UrlParameter.Optional }
);

There are no other routes above this route, but whenever I try and access the above route with a path value that has an .svc extension, for example:

http://localhost/MyVirtualDirectory/mycontroller/test/somepath.svc

ASP.Net returns a 404 error without executing my controller (I have a log message call at the start of the action method). If I change the extension to something benign (like .txt) it works perfectly, so seems that somewhere along the line ASP.Net is interpreting the request as a standard ASP.Net call to a web service that doesn't exist - this is definitely an ASP.Net 404 response (not an IIS response).

What could be causing this, and how do I stop it from happening?

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about iis7