Asp.Net MVC - 领域

时间:2009-11-09 10:20:58

标签: asp.net-mvc asp.net-mvc-areas

我在看这里的Haacks文章 - http://haacked.com/archive/2009/07/31/single-project-areas.aspx

下载示例时,我在Global.ascx

中收到以下错误
  

错误1'System.Web.Routing.RouteCollection'   不包含的定义   'MapAreaRoute'并没有扩展方法   'MapAreaRoute'接受第一个   类型的论证   'System.Web.Routing.RouteCollection'   可以找到(你错过了吗?   使用指令或程序集   引用?)

我认为我显然缺少某些东西,任何人都有什么想法?

1 个答案:

答案 0 :(得分:2)

您现在应该在新实现中使用“AreaRegistration.RegisterAllAreas”

此博文可能对您有用:

http://suhair.in/Blog/aspnet-areas-in-depth

博客中的代码片段:

protected void Application_Start()
{
     AreaRegistration.RegisterAllAreas(); 1
     RegisterRoutes(RouteTable.Routes);
}

...加

public static void RegisterAllAreas() 
{
      RegisterAllAreas(null);
}

public static void RegisterAllAreas(object state) 
{
                                 2                        3
      RegisterAllAreas(RouteTable.Routes, new BuildManagerWrapper(), state);
}