Route management / Global.asax compatible

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());
    // etc., for each controller
}

Include() - , IRoutedController, Include() a IEnumerable<Route> Route RouteCollection.

: , route.MapRoute(), , URL-, , URL- IRoutedController , , URL- , . , , 75+ Route Global.asax.cs.

?

?

Global.asax.cs; ; - ? (, URL , .)

+3
2

, ?: P

routes.MapRoute(
    "Default", 
    "{controller}/{action}/{id}", 
    new { controller = "Home", action = "Index", id = UrlParameter.Optional } 
);

.


?

, .

?

. .

Global.asax.cs; ; - ?

, . , .

(, URL , .)

, , , .. {controller}/{action}

+2

xml global.asax. /, URL- , . , (, , .., dll).

+1

Source: https://habr.com/ru/post/1765218/


All Articles