How do ASP.NET MVC Routes work?
        Posted  
        
            by Pure.Krome
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Pure.Krome
        
        
        
        Published on 2010-03-13T14:29:34Z
        Indexed on 
            2010/03/13
            14:35 UTC
        
        
        Read the original article
        Hit count: 398
        
asp.net-mvc
|routes
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!
© Stack Overflow or respective owner