MVC area route resolution

倖福魔咒の 提交于 2019-12-24 03:23:28

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!