发现多个类型与名为“Home”的控制器相匹配 – 在两个不同的区域中

我的项目有两个方面。 现在,当我运行程序时,我收到此错误:

Multiple types were found that match the controller named 'Home'. This can happen if the route that services this request ('{controller}/{action}/{id}') does not specify namespaces to search for a controller that matches the request. If this is the case, register this route by calling an overload of the 'MapRoute' method that takes a 'namespaces' parameter. The request for 'Home' has found the following matching controllers: BaseAdminMVC.Areas.BaseAdmin.Controllers.HomeController BaseAdminMVC.Areas.TitomsAdmin.Controllers.HomeController 

我在这里找到了一些来源: 多个控制器名称
但我认为这只适用于一个领域。
就我而言,我在不同领域有两个项目。 希望有人能告诉我该怎么做才能解决问题。
这是Global.asax文件:

 public static void RegisterRoutes(RouteCollection routes) { string[] namespaces = new string[] { "BaseAdminMVC.Areas.BaseAdmin.Controllers", "BaseAdminMVC.Areas.TitomsAdmin.Controllers"}; routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter.Optional }, namespaces ); } 

顺便说一句,我还有Area文件夹外的控制器(“ HomeController ”)。 这只提供了两个项目BaseAdminTitomsAdmin

我试过这个解决方案,但仍然无效

 routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); routes.MapRoute( "BaseAdmin", "BaseAdmin/{controller}/{action}", new { controller = "Account", action = "Index" }, new string[] { "BaseAdminMVC.Areas.BaseAdmin.Controllers" } ); routes.MapRoute( "TitomsAdmin", "TitomsAdmin/{controller}/{action}", new { controller = "Home", action = "Index" }, new string[] { "BaseAdminMVC.Areas.TitomsAdmin.Controllers" } ); 

提前致谢!!

我不知道发生了什么,但这段代码工作正常:

 public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter.Optional }, new string[] { "BaseAdminMVC.Areas.TitomsAdmin.Controllers" } ); } 

在重命名我的项目命名空间/程序集后,我收到此错误。

如果重命名了命名空间/程序集,则可能是bin文件夹中以前名称的剩余程序集/ dll。 只需从那里删除它,它应该工作。

右键单击该项目,然后选择清理项目。 或者完全清空bin目录,然后重新构建。 这应该清除任何剩余的组件