Below Code will add new custom routes. This will allow you to call same Controller Action method with different URLs.
e.g.:
1.http://localhost:25562/NewHome
2.http://localhost:25562/Home
URL will call Home controller Index method.
- public class RouteConfig
- {
- public static void RegisterRoutes(RouteCollection routes)
- {
- routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
-
- routes.MapRoute(
- name: "HomeRoute",
- url: "Home",
- defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
- );
-
- routes.MapRoute(
- name: "NewHomeRoute",
- url: "NewHome",
- defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
- );
-
- routes.MapRoute(
- name: "Default",
- url: "{controller}/{action}/{id}",
- defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
- );
- }
- }