İlk böyle Global.asax kendine bir yardımcı yöntemini hazırlamak:
private static void RegisterArea<T>(RouteCollection routes, object state) where T : AreaRegistration
{
AreaRegistration registration = (AreaRegistration)Activator.CreateInstance(typeof(T));
AreaRegistrationContext registrationContext = new AreaRegistrationContext(registration.AreaName, routes, state);
string areaNamespace = registration.GetType().Namespace;
if (!String.IsNullOrEmpty(areaNamespace))
registrationContext.Namespaces.Add(areaNamespace + ".*");
registration.RegisterArea(registrationContext);
}
Şimdi böyle Application_Start manuel kayıt için bu yardımcı yöntemini kullanabilirsiniz:
//Replace AreaRegistration.RegisterAllAreas(); with lines like those
RegisterArea<FirstAreaRegistration>(RouteTable.Routes, null);
RegisterArea<SecondAreaRegistration>(RouteTable.Routes, null);
AreaRegistration sınıfları vardır Yeni Alan eklediğinizde Visual Studio tarafından oluşturulan, bunları Fields/AreaName dizinlerinde bulabilirsiniz.