forum

Home / DeveloperSection / Forums / How to RegisterRoute in mvc?

How to RegisterRoute in mvc?

Samuel Fernandes175909-Oct-2014
I would like to rewrite the url from

http://localhost:51639/home/index?id=123
to
http://localhost:51639/home/product
Here is my code in Global.asax.cs

publicstaticvoid RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
 
            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
            );
        }



Updated on 09-Oct-2014

Can you answer this question?


Answer

1 Answers

Liked By