I have the following routes defined:
routes.MapRoute(
"Content Pages",
"{action}",
new { controller = "Pages", action = "Index" });
routes.MapRoute(
"Default",
"{controller}/{action}/{id}/{title}",
new { controller = "Home", action = "Index",
id = UrlParameter.Optional,
title = UrlParameter.Optional },
new string[] { "MyCompany.Web.Controllers" });
I have a controller named Pages that has some actions like “About”, “FAQ” etc that I would like to access like this: mywebsite.com/About
This currently works, but now all of my other controllers end up specifying their default action in the url. My action link for Books renders as mywebsite.com/Books/Index.
How can I modify my routes so that I can achieve this?
I would have a more generic route for all your other controllers like this (but put it after the Page routes below)
and change your Pages one to be more specific for those two actions (assuming you have not got an About or Faq controller).