本文介绍了命名空间更改 - 发现多个类型与名为“Home"的控制器匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更改 mvc 项目的命名空间后遇到以下问题:

I ran into the following problem after changing the namespace for my mvc project:

找到多个与名为Home"的控制器匹配的类型.如果为此请求提供服务的路由 ('{controller}/{action}/{id}') 没有指定命名空间来搜索与请求匹配的控制器,就会发生这种情况.如果是这种情况,请通过调用采用namespaces"参数的MapRoute"方法的重载来注册此路由.

对Home"的请求已找到以下匹配的控制器:

The request for 'Home' has found the following matching controllers:

oldns.Controllers.HomeController

oldns.Controllers.HomeController

newns.Controllers.HomeController

newns.Controllers.HomeController

关于此错误还有其他已回答的问题,但涵盖了其他原因:

There are other answered questions about this error, but cover other causes:

推荐答案

经过一番研究,我发现原因是旧的 mvc app dll 残留在 bin 文件夹 (binoldns.dll) 中.清洁并没有清除它.我手动删除了bin目录的内容,然后一切正常.

After doing some research, I found that the cause was the old mvc app dll remaining in the bin folder (binoldns.dll). Clean was not clearing it out. I manually deleted the contents of the bin directory and then all was well.

这篇关于命名空间更改 - 发现多个类型与名为“Home"的控制器匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!