sainture
5/11/2016 - 1:13 PM

Routing

Routing

// Routing configuration is setup in App_Start / RouteConfig.cs file

public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
          
            // default route which matches first element after root url with controller name 
            // then action (method) and then id (optional) 
            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );           

        }
    }
    
// you also define your own rules e.g.
// this rule will match "/serial" after the root url and the default settings will 
// call HomeController's Serial method
routes.MapRoute(
              name: "Serial number",
              url: "serial",
              defaults: new { controller = "Home", action = "Serial" }
);