mvc 4区域注册排序



在MVC路由我有一个问题。

在基本路由中,您可以通过按您希望的顺序编写路由来简单地对它们进行排序。如下所示:

        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); 
    } 
}

这是一个抽象类AreaRegistration的方法,其中调用所有自定义区域注册类。如您所见,没有排序。在TypeCacheUtil.GetFilteredTypesFromAssemblies方法的更深处,也没有排序。

我看不到任何方法使用AreaRegistration类的可订购区域注册。类没有任何可用于此目的的扩展点

最新更新