How can I turn this /Home/About/ into just /About/ using the rules in the Global.aspx file?
5 Answers
public static void RegisterRoutes(RouteCollection routes)
{
routes.MapRoute(
"About", // Route name
"About", // URL
new { controller = "Home", action = "About" });
...
}
@Scott: Thanks. Fixed it.
1 Comment
Scott Lance
Putting the / at the beginning of the URL will cause an ArgumentException error
I used this:
routes.MapRoute(
"HomeActions",
"{action}",
new
{
controller = "Home",
action = "Index" // I technically don't think this is required.
},
new // The second object are route constraints
{
action = "Index|FAQ|ContactUs|Examples|Materials|Members" // <-- various actions on my home controller. Any regex works here.
});