Reputation: 6516
Is there anyway to make all actions in a given controller to redirect to the server root?
For example, if I have a URL with controller Home and action terms I want that to the URL to become /terms
If I have another URL with controller Home and action privacy, then the URL should become /privacy.
I am able to do this by hard-coding 2 routes, but is there a way to automatically do this?
routes.MapRoute(
"Term",
"terms",
new { controller = "Home", action = "terms" }
);
routes.MapRoute(
"Privacy",
"privacy",
new { controller = "Home", action = "privacy" }
);
Upvotes: 3
Views: 1811
Reputation: 1038930
routes.MapRoute(
"ActionOnly",
"{action}",
new { controller = "Home" }
);
Upvotes: 6