标签:
ASP.NET MVC 复制MVC项目代码到同一个项目的时候报错The request for ‘home’ has found the following matching controll “/”应用程序中的服务器错误。 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:
ET_Fund.M.Controllers.HomeController
ET_Fund.Mv3.Controllers.HomeController
说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.InvalidOperationException: 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:
ET_Fund.M.Controllers.HomeController
ET_Fund.Mv3.Controllers.HomeController
源错误:
执行当前 Web 请求期间生成了未经处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。
堆栈跟踪:
版本信息: Microsoft .NET Framework 版本:4.0.30319; ASP.NET 版本:4.6.1073.0
解决方法:
1 public static void RegisterRoutes(RouteCollection routes) 2 { 3 //routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 4 5 //routes.MapRoute( 6 // name: "Default", 7 // url: "{controller}/{action}/{id}", 8 // defaults: new { controller = "home", action = "Index", id = UrlParameter.Optional } 9 //); 10 11 routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 12 13 routes.MapRoute( 14 name: "Default", 15 url: "{controller}/{action}/{id}", 16 defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }, 17 namespaces: new[] { "ET_Fund.Mv3.Controllers" } // 此处的 et_fund.mv3 为新的控制器的名词 18 ); 19 }
原创: 文章来自:
ASP.NET MVC 复制MVC项目代码到同一个项目的时候报错The request for ‘home’ has found the following matching controll