HOW TO CHANGE URL USING URL ROUTING IN MVC?

Manoj Pandey

Total Post:26

Points:188
Posted by  Manoj Pandey
 880  View(s)
Ratings:
Rate this:

Hi I’m working with url routing.

My question is my actual controller is Home and action is Index when run application give the appropriate result that time url is Home/Index.

But I’m want to when type url Dashboard/Index that time execute Home controller index method.

How to possible.

Thank you in advance.

  1. Tom Cruser

    Post:28

    Points:196
    Re: How to change url using url routing in mvc?

    Just add this route in RouteConfig.cs file make sure to add this before default route otherwise this is not work.

    routes.MapRoute(

                     name: "OldURL",

                     url: "Dashboard/{action}/{id}",

                     defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }

                 );

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!