2011-07-19 88 views
8

我在我的asp.net mvc 3解決方案中創建了一個名爲admin的新區域。 Visual Studio中自動分配的名稱空間:ASP.NET MVC區域命名空間問題

MyApp.areas.admin.controllers 

我將其更改爲MyApp.admin.controllers

,但是它停止解析的動作。
在這方面的任何幫助將不勝感激。
謝謝

+3

爲什麼命名空間回事? –

+0

你有沒有改變別的?移動文件,重命名文件夾,從區域註冊文件中刪除路線註冊? – dreza

回答

16

您需要在註冊管理區域的路由時指定新的命名空間。

在您的\區\ ADMIN \ adminAreaRegistration.cs文件,需要如下修改RegisterArea()方法:

public override void RegisterArea(AreaRegistrationContext context) 
{ 
    context.MapRoute(
     "admin_default", 
     "admin/{controller}/{action}/{id}", 
     new { action = "Index", id = UrlParameter.Optional }, 
     new string[] { "MyApp.admin.Controllers" } // specify the new namespace 
    ); 
}