I’ve got an issue with the ASP.NET MVC framework routing taking the URL route I need for a HttpHandler via its default route, and visa versa:
routes.MapRouteLowercase(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional });// Parameter defaults
I’ve tried ignoring the route I need:
routes.IgnoreRoute("api/{*pathInfo}");
If I add to the RouteTable before the MVC routes are added, all the MVC routes end up pointing to my “/api” route.
If I add them after, the routes are in the routing table but not recognised. I’ve tried using the RouteDebugger which does show my routes as matching, but they’re never called.
The source is in this micro REST framework I’m writing, if that helps.
I’ve found a work around for it, but it doesn’t explain why my Routes are chomping at the MVC routes when the urls do not start with “api/” at all.
The work around I’m using is to add a constraint to my routes which checks if it’s a Url generation, and ignore it, and if it’s MVC data being passed in:
The constraint: