I have already managed to get friendly urls working with my cms; however, what i want to know is: with asp.net 4.0 routes options, how do i get a root leaving routing? When user types in http://www.mysite.com/page_name, which is aboutus, it goes to the page cms.aspx but leaves the other routes intact:
routes.Clear();
// Register a route for Products/{ProductName}
routes.MapPageRoute(
"View Product", // Route name
"Products/{ProductName}", // Route URL
"~/products.aspx" // Web page to handle route
);
// Register a route for Products/{ProductName}
routes.MapPageRoute(
"ShoppingCart", // Route name
"{ShoppingCart}", // Route URL
"~/Basket.aspx" // Web page to handle route
);
// Register a route for Products/{ProductName}
routes.MapPageRoute(
"ShoppingCart", // Route name
"{ShoppingCart}", // Route URL
"~/Basket.aspx" // Web page to handle route
);
// --->> How do i do this
// Register a route for url/{pagename}
routes.MapPageRoute(
"cms", // Route name
"{}", // Route URL
"~/cms.aspx" // Web page to handle route
);
I think you’re looking for a root controller. This will allow you to eliminate the controller name and just have:
{url}/action
It sounds like your intention is to clean up the URL’s?
See: Having trouble with a simple MVC route