Asp.net mvc 4 MVC4区域寄存器排序
在MVC路由中,我遇到了一个问题 在“基本路由”中,您只需按自己希望的顺序对路由进行排序。如下图所示:Asp.net mvc 4 MVC4区域寄存器排序,asp.net-mvc-4,routes,area,Asp.net Mvc 4,Routes,Area,在MVC路由中,我遇到了一个问题 在“基本路由”中,您只需按自己希望的顺序对路由进行排序。如下图所示: routes.MapRoute( "Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = UrlParameter.Optional }, new [] {"
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional },
new [] {"SampleApp.UI.Web.Controllers"}
);
routes.MapRoute(
"CompanyRoute",
"{Company_url}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional },
new[] { "SampleApp.UI.Web.Controllers" }
);
区域呢
在特殊情况下,我需要先注册一个区域,然后再注册另一个区域。
如何对区域路线进行排序?根据我在反汇编程序的帮助下得出的结论:
internal static void RegisterAllAreas(RouteCollection routes, IBuildManager buildManager, object state) {
List<Type> areaRegistrationTypes = TypeCacheUtil.GetFilteredTypesFromAssemblies(_typeCacheName, IsAreaRegistrationType, buildManager);
foreach (Type areaRegistrationType in areaRegistrationTypes) {
AreaRegistration registration = (AreaRegistration)Activator.CreateInstance(areaRegistrationType);
registration.CreateContextAndRegister(routes, state);
}
}
内部静态无效注册表区域(RouteCollection routes、IBuildManager buildManager、对象状态){
List Area RegistrationTypes=TypeCacheUtil.GetFilteredTypesFromAssemblies(\u typeCacheName,IsAreaRegistrationType,buildManager);
foreach(类型areaRegistrationType中的类型areaRegistrationType){
AreaRegistration=(AreaRegistration)Activator.CreateInstance(areaRegistrationType);
注册。CreateContextAndRegister(路线、州);
}
}
这是一个抽象类AreaRegistration
的方法,其中调用了所有自定义区域注册类。正如你所看到的,没有订单。在TypeCacheUtil.GetFilteredTypesFromAssemblies
方法的更深处,也没有排序
我看不到任何使用AreaRegistration
类进行可订购区域注册的方法。该类没有任何可用于此目的的扩展点