Topic: Route Registration Examples
Share/Save/Bookmark
Description: These are a few examples of how to register routes
Notes:

Eamples:

        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
 
            routes.MapRoute(
                "Default1",                                              // Route name
                "{controller}/{action}/{category}",                           // URL with parameters
                new { controller = "Home", action = "Index", category = "" }, // Parameter defaults
                    new { category = @"\w[A-Za-z&=]{2,50}" }
            );
 
            routes.MapRoute(
                "Default2",                                              // Route name
                "{controller}/{action}/{id}/{productType}",                           // URL with parameters
                new { controller = "Home", action = "Index", id = "" },  // Parameter defaults
                    new { productType = @"\w[A-Za-z&=]{2,50}" }
            );
 
 
            routes.MapRoute(
                "Default",                                              // Route name
                "{controller}/{action}/{id}",                           // URL with parameters
                new { controller = "Home", action = "Index", id = "" }  // Parameter defaults
            );
 
        }
 
        protected void Application_Start()
        {
            RegisterRoutes(RouteTable.Routes);
        }