Md Tahmidul Abedin
In ASP.Net, can we map multiple URLs to the same action.
By Md Tahmidul Abedin in ASP.NET on Oct 22 2018
  • Vikas Agarwal
    Oct, 2018 26

    Yes, We can use multiple URLs to the same action with the use of a routing table. foreach(string url in urls)routes.MapRoute("RouteName-" + url, url, new { controller = "Page", action = "Index" });

    • 5
  • Sudarshan Hajare
    Jul, 2019 16

    You can map URL by giving two different key name and specify the same action and same controller in RegisterRoutes() Method.

    routes.MapRoute(
    name: “myRoute”,
    url: “Home/{pageName}”,
    defaults: new { controller = “Home”, action = “Index”, pageName = UrlParameter.Optional }
    );

    1. routes.MapRoute(
    2. name: "Default",
    3. url: "{controller}/{action}/{id}",
    4. defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
    5. );

    • 1
  • Laxmidhar Sahoo
    Nov, 2018 10

    routes.MapRoute(name: "categories",url: "categories",defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional });routes.MapRoute(name: "products",url: "products",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 });

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS