2014-01-16 47 views
0

我正在創建MVC應用程序,其中我有幾個域,並根據域將它去特定區域。MVC路由,註冊一個特定區域而不是全部

當應用程序啓動應用程序調用AreaRegistration.RegisterAllAreas(); 有沒有辦法註冊一個特定區域而不是全部?

在此先感謝。

+0

'RegisterAllAreas'主要用於註冊區域的路線。如果你不想註冊這些路由,你可以設置一個appSetting或類似的配置,並且只使用該變量來決定是否註冊該區域的路由。爲什麼你正在尋找這個功能? – danludwig

回答

-1

閱讀關於area registration class我希望這將有助於完成此任務。 查看示例:

public class BlogAreaRegistration : AreaRegistration 
{ 
public override string AreaName 
{ 
    get 
    { 
     return "Blog"; 
    } 
} 

public override void RegisterArea(AreaRegistrationContext context) 
{ 
    context.MapRoute(
     "Blog_default", 
     "Blog/{controller}/{action}/{id}", 
     new { action = "Index", id = "" } 
    ); 
} 
}