问题
Using MVC3/4 if you have area's in your solution, what is the order that it will try and resolve the areas and root level controllers?
For example:
Does it first try the root level routes and then the area level routes in alphabetical order?
Or does it first check the area level routes in alphabetical order and then the root level?
Thanks
回答1:
MVC resolvers area specific routes first and then root level routes. This is because by default you have next code in Global.asax:
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas(); //1. registers areas
RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes); //2. only after that register root routes
}
I have not tried it but if you would like to change this behavior you may try to swap these code lines in you project.
来源:https://stackoverflow.com/questions/12293657/mvc-area-route-resolution