System.InvalidOperationException: The controller name 'Index' is ambiguous between the following types (mvc2)

.net mvc2 多个Area下Controller名字一样,报错

 System.InvalidOperationException: The controller name 'Index' is ambiguous between the following types

中文版错误提示: 

找到了多个与名为“Home”的控制器匹配的类型。如果为此请求(“{controller}/{action}/{id}”)提供服务的路由没有指定命名空间来搜索匹配此请求的控制器,则会发生此情况。如果是这样,请通过调用采用“namespaces”参数的“MapRoute”方法的重载来注册此路由。

,解决办法:

  routes.MapRoute(
      "Default", 
      "{controller}/{action}/{id}",

 
      new { controller = "Home", action = "Index", id = "" },

  new String[] { "名称空间,到area名称.Controllers" }          // namespace 

     );

 

 

参考: http://odetocode.com/Blogs/scott/archive/2009/10/13/asp-net-mvc2-preview-2-areas-and-routes.aspx

原文地址:https://www.cnblogs.com/jifsu/p/1673457.html