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 请求期间生成了未经处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。

堆栈跟踪:

[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]
System.Web.Mvc.DefaultControllerFactory.GetControllerTypeWithinNamespaces(RouteBase route, String controllerName, HashSet`1 namespaces) +429733
System.Web.Mvc.DefaultControllerFactory.GetControllerType(RequestContext requestContext, String controllerName) +576
System.Web.Mvc.DefaultControllerFactory.System.Web.Mvc.IControllerFactory.GetControllerSessionBehavior(RequestContext requestContext, String controllerName) +61
System.Web.Mvc.MvcRouteHandler.GetSessionStateBehavior(RequestContext requestContext) +157
System.Web.Mvc.MvcRouteHandler.GetHttpHandler(RequestContext requestContext) +33
System.Web.Mvc.MvcRouteHandler.System.Web.Routing.IRouteHandler.GetHttpHandler(RequestContext requestContext) +12
System.Web.Routing.UrlRoutingModule.PostResolveRequestCache(HttpContextBase context) +9836207
System.Web.Routing.UrlRoutingModule.OnApplicationPostResolveRequestCache(Object sender, EventArgs e) +82
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +141
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69

版本信息: Microsoft .NET Framework 版本:4.0.30319; ASP.NET 版本:4.6.1073.0

解决方法:

 public static void RegisterRoutes(RouteCollection routes)
{
//routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); //routes.MapRoute(
// name: "Default",
// url: "{controller}/{action}/{id}",
// defaults: new { controller = "home", action = "Index", id = UrlParameter.Optional }
//); routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
namespaces: new[] { "ET_Fund.Mv3.Controllers" } // 此处的 et_fund.mv3 为新的控制器的名词
);
}

原创: 文章来自:

http://www.lesg.cn/wentiji/2017-909.html

最新文章

  1. 针对每种Windows Server 操作Excel、Word等Office组件遇到“ComException"、”80070005“等COM错误的解决方案大汇总
  2. mongoperf用法
  3. Python:dict用法
  4. Python 2.7_初试连接Mysql查询数据导出到excel_20161216
  5. Android自定义控件3--优酷菜单执行动画
  6. [转]asp.net c# 网上搜集面试题目(附答案)
  7. 多列布局——column-count
  8. viewpager接受值图片轮播
  9. DS实验题 Inversion
  10. JS框架整理
  11. Mac安装wget的两种方法
  12. PHP文件上传与安全
  13. css3 翻书效果
  14. 于Unity3D动态创建对象和创建Prefab三种方式的原型对象
  15. 收官之作:利用Microsoft Teams构建中大型社区的技术架构与运营经验
  16. spring4笔记----使用装配注入合作者Bean的三种方式
  17. Javassist之使用字节码在运行时生成新的类 01
  18. Apache commons(Java常用工具包)简介
  19. OEM、ODM、OBM、OPM概念,作用与区别
  20. Springboot监控之一:SpringBoot四大神器之Actuator之2--覆盖修改spring cloud的默认的consul健康检查规则

热门文章

  1. codeforces 701D D. As Fast As Possible(数学)
  2. hdu-5358 First One(尺取法)
  3. 静态路由配置及RIP配置实验
  4. css 内容超出宽度自动换行
  5. ftp连接服务器失败||或者Xshell链接错误:Could notconnect to '192.168.18.128' (port 22): Connection failed
  6. 洛谷 1312 Mayan游戏——暴搜+剪枝
  7. Objective-C 中nil/Nil/NULL/NSNull
  8. 注销ie中的ActiveX插件
  9. stdout引发的curl 302跳转 crash
  10. Asset Catalog Help (五)---Migrating an iOS App Icon Set or Launch Image Set