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

ASP.NET MVC 复制MVC项目代码到同一个项目的时候报错The request for ‘home’ has found the following matching controll的更多相关文章

  1. php项目代码 编码格式不对会大范围报错

    php项目代码 编码格式不对会大范围报错

  2. asp.net textbox等服务器控件包含html代码的时候,提交会报错

    asp.net  textbox等服务器控件包含html代码的时候,提交会报错,页面中的其他按钮点击的时候也会报错误, 解决方法: Page里加上这个属性 ValidateRequest=" ...

  3. laravel 项目表单中有csrf_token,但一直报错419错误 解决redis连接错误:MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persi

    laravel 项目表单中有csrf_token,但一直报错419错误,因为项目中使用到Redis缓存,在强制关闭Redis后出现的问题,查询laravel.log文件查找相关问题 安装redis后在 ...

  4. 关于导入本地maven项目pom.xml出现missing artifact org....报错处理

    一.导入本地maven项目步骤:

  5. 创建一个MVC解决方案,添加一个控制器后,运行程序报错:”/"未找到服务器

    1.创建一个MVC项目,如图

  6. 前端vue项目部署到tomcat,一刷新报错404解决方法

    公司前端写的后台部署到tomcat webapps目录下后,无法进行刷新,一刷新就会报错404,自动跳的404页面.在网上查了下,官方说是HTML5 History 模式引发的问题,但是解决方案中,并 ...

  7. vue-cli新建vue项目安装axios后在IE下报错

    使用脚手架新建了一个vue项目,可以在IE9+浏览器运行,但是在添加了axios后,在IE下就报错了 首先是安装axios,在命令行执行: $ npm install axios -s //执行命令, ...

  8. eclipse项目转移至IDEA与IDEA tomcat报错(idea自带tomcat版本太高)与war包部署到win服务器与idea提交git的总结

    eclipse导出项目到idea时,不要导出target: idea打开eclipse项目后,出现junit找不到的问题,原因是jar包缺失,而maven配置的低版本的junit也显示找不到,解决办法 ...

  9. create-react-app创建项目后运行npm run eject命令报错解决办法

    最近在用create-react-app创建项目,因要配置各种组件,比如babel,antd等, 需要运行npm run eject命令把项目的配置文件暴露出来,但是还是一如既然碰到报错,因为是在本地 ...

随机推荐

  1. JDBC 笔记3 通过PreparedStatement 对数据库进行增删改查 (转载)

    之前MVC时一直用它,学了框架后就没怎么用了.这里转载一位同学的博客,以后可能也会用到的. 转自:https://www.cnblogs.com/zilong882008/archive/2011/1 ...

  2. 001-将Python源码转换为不需要环境的可执行文件

    1 安装pyinstaller pip install pyinstaller #或者 pip3 install pyinstaller 2 生成打包文件 在命令行中输入 pyinstaller -F ...

  3. bzoj 3027 [Ceoi2004] Sweet —— 生成函数

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=3027 就是 (1+x+x2+...+xm[i]) 乘起来: 原来想和背包一样做,然而时限很短 ...

  4. MTK OTG 流程

    一.注册mt_usb驱动 kernel-3.18/drivers/misc/mediatek/usb20/mt6735/usb20.c static int __init usb20_init(voi ...

  5. js数组,在遍历中删除元素(用 for (var i in arr)是无效的 )

    /** * 有效的方式 - 改变下标,控制遍历 */ for (var i = 0; i < arr.length; i++) { if (...) { arr.splice(i, 1); // ...

  6. Java全栈工程师知识体系介绍

    Java全栈工程师,是指掌握多种技能,并能利用多种技能独立完成产品的人,也叫全端工程师(同时具备前端和后台能力),英文Full Stack developer. 那么想要成为一名合格的Java全栈工程 ...

  7. UICollctionView 刷新 item 刷新 消失

    在需要局部刷新的时候,可能出现的问题: 当时采用的局部刷新,第一次刷新没问题,当多次刷新的时候 item 就会消失 NSIndexSet *]; [collectionView reloadSecti ...

  8. webstrom打开多个项目,webstrom常用快捷键

    1.webstrom打开多个项目 默认情况下一次只能打开一个项目,如果需要打开多个就按照下面的方法 File -> settings -> Directories -> Add Co ...

  9. JavaScript之——对象Object(一)

    1. 新建对象.删除和访问: (1).新建 var obj1 = {b: 2}; //对象文本表示法 var obj2 = new Object(); obj2.a = 1; (2).访问 //第一种 ...

  10. 微信API接口文档

    传送门