Hi guys!
I'm currently working on an e-store using ASP.NET MVC 2.0. I already got most of it up and running, but the part that's been bothering me is routing. I want this:
http://mystore.somewhere/my-category-1/
So far I've been able to solve it by using:
routes.MapRoute(
"Category",
"{alias}/{pageNumber}",
new { controller = "Categories", action = "Browse", pageNumber = 1 });
But this catches way too much than just what I'd like.
After reading through some questions and answers around this site, I found a particulary interesting solution that would require me to programatically register a route for each of my categories, so in essence I'd be doing
foreach (var c in Categories)
{
routes.MapRoute(
c.Name,
"{" + c.Alias + "}/{action}/...anything else",
new { controller = "Category", action = "Index" }).RouteHandler = new CateegoryRouteHandler(c);
}
What do you think? Is this a good idea? I'm probably going to have about 200 categories, is that too much "routes" to have in the routing table? Would you suggest another solution?
Thanks.
Regards, Anže