ASP.Net MVC 404 errors when route contains an .svc extension
- by Kragen
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?