2011-07-19 89 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 
    ); 
}