I need the following routes:
example.com/products
goes to a product categories page (e.g. cars, trucks, buses, bikes)
controller=Products
Introduce Parameters. ASP.NET MVC allows you to create 'pretty' URLs, and that's exactly what you should do here:
First, the route mappings:
routes.MapRoute(
"SpecificProducts",
"products/{a}/{b}",
new { controller = "products", action = "Categories" }
);
routes.MapRoute(
"ProductsIndex",
"products".
new { controller = "products", action = "Index" }
);
Then, the controller actions
public ActionResult Index()
{
}
public ActionResult Categories(string a, string b) //parameters must match route values
{
}
This will allow you to use a search-friendly URL and you don't have to worry about query string parameters.