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. HDU-2255(KM算法)

    HDU-2255 题目意思转化之后就是,给你一个二分图(也称 二部图) ,要求选择一些边让左边的点都对应左边的某一个点!该问题也叫做二分图最大匹配.所以可以用KM算法来做这道题.KM前提你要理解匈牙利 ...

  2. windows下使用emacs+plink远程编辑erlang文件

    1)plink.exe属于putty套件, 注册到环境变量;emacs的bin目录也要注册到环境变量中; 2)在.emacs中增加如下: (require 'tramp)(setq tramp-def ...

  3. 小trick之mklink

    因为要看很多论文就下载安装了zotero,又因为文献库的文件夹在安装目录太深,找起来太麻烦,再加上是软件本身的安装目录,因此把论文都下载在默认文件中总会天然地产生不安全感,万一误删软件怎么办.所以在文 ...

  4. [HAOI 2012] Road

    [题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=2750 [算法] 考虑计算每个点对每条边的贡献 对于每个点首先运行SPFA或Dijks ...

  5. exBSGS算法

    BSGS,全称\(Baby Step Giant Step\),是用于求解离散对数的一种算法. 就是用来求\(A^x \equiv B (mod\ p)\) 的x这么一种算法-- 理论知识是:在[0, ...

  6. Android开发--Intent

    一:Intent基础知识 Intent:信使,实现四大组件间的通信. 1:实现页面间的跳转,有两种方式: (1):startActivity()方式: (2) 2:使用Intent传递数据的四种方式: ...

  7. ECMAScript 6 &ECMAScript 5(在线手册)

    https://www.w3.org/html/ig/zh/wiki/ES5#.E8.A1.A8.E8.BE.BE.E5.BC.8F      ECMAScript 5(在线手册) http://es ...

  8. CF-796B

    B. Find The Bone time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...

  9. Flutter实战视频-移动电商-07.Dio基础_POST请求的使用

    07.Dio基础_POST请求的使用 越界问题解决 容器越界的问题,越界是因为键盘弹起的问题.如果键盘不弹起是不会越界 我们加一个滚动组件就可以解决. 这是技术胖视频中出现的越界的截图效果 这是我自己 ...

  10. Flutter实战视频-移动电商-24.Provide状态管理基础

    24.Provide状态管理基础 Flutter | 状态管理特别篇 —— Provide:https://juejin.im/post/5c6d4b52f265da2dc675b407?tdsour ...