Is there any best practice for how best to define and organize routes in MVC?
The company I work with works on a very extensive, complex e-commerce site with ~ 600 thousand unique visitors / days.
Here's the problem: in our Global.asax.cs we have this HUGE list of about 75 route definitions in ours RegisterRoutes():
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
Is there a better way to define these routes besides having this giant list in Global.asax.cs?
Since we have a bunch of developers, and half of them are incompetent, and I can’t return to refactoring these routes, in just a couple of minutes you can understand which controller is responsible for delivering the URL.
What can I do?
, Global.asax.cs:
public static void RegisterRoutes(RouteCollection routes)
{
routes.Include(new RootController());
routes.Include(new AccountController());
routes.Include(new HelpController());
routes.Include(new SearchController());
}
Include() - , IRoutedController, Include() a IEnumerable<Route> Route RouteCollection.
: , route.MapRoute(), , URL-, , URL- IRoutedController , , URL- , . , , 75+ Route Global.asax.cs.
?
?
Global.asax.cs; ; - ? (, URL , .)