ftdeveloper
ftdeveloper

Reputation: 1093

Asp.net mvc url routing. Change url

My controller is "/Home/Index".I want, when i type url to "/Dashboard/Index" or "example.com/Dashboard" my "/Home/Index action method" executed. Can you give me starting point?

Upvotes: 0

Views: 3055

Answers (1)

Steve Michelotti
Steve Michelotti

Reputation: 5213

Just add this route to your route config. Make sure to add it before the default route:

routes.MapRoute(
    name: "HomeRoute",
    url: "Dashboard/{action}/{id}",
    defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);

Upvotes: 2

Related Questions