I would like to create a custom routing in my app.
I added a new route in the Global asax file:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Profile", // Route name
"{controller}/{action}/{userName}", // URL with parameters
new { controller = "UserProfile", action = "Index", userName = UrlParameter.Optional } // Parameter defaults
);
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
It works fine when I use the UserProfileController:
http://localhost:7738/UserProfile/Info/chopin
But the Default routing is not working!
I see this http://localhost:7738/Blog/Info?id=2 instead of this http://localhost:7738/Blog/Info/2
Anybody can help me?
Thanks l.