How do ASP.NET MVC Routes work?
- by Pure.Krome
Hi folks,
imagine i have the following route setup...
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = "" }
);
// Added custom route here!
routes.MapRoute(
"CatchAll",
"{*catchall},"
new { controller = "Error", action = "NotFound" }
);
}
nothing new - that's the default ASP.NET MVC1 RegisterRoutes method, with one custom route added.
Now, if I goto the following url, i get a 404...
http://whatever/Home/MissingActionMethod
So there's no ActionMethod called MissingActionMethod in the HomeController. So, does this mean, if i goto the 1st route defined, above .. and fail to find an action .. do I then come back and try the second route? rinse-repeat?
Or once i match a route, i then try and execute that route .. and if i fail (ie, find the action is missing) .. then .. bad luck? boomski?
cheers!