Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
399 views
in Technique[技术] by (71.8m points)

c# - Multiple types were found that match the controller named 'Home'

I currently have two unrelated MVC3 projects hosted online.

One works fine, the other doesn't work, giving me the error:

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 way my hoster works is that he gives me FTP access and in that folder I have two other folder, one for each of my applications.

ftpFolderA2/foo.com

ftpFolderA2/bar.com

foo.com works fine, I publish my application to my local file system then FTP the contents and it works.

When I upload and try to run bar.com, the issue above fires and prevents me from using my site. All while foo.com still works.

Is bar.com searching from controllers EVERYWHERE inside of ftpFolderA2 and that's why it's finding another HomeController? How can I tell it to only look in the Controller folder as it should?

Facts:

  1. Not using areas. These are two COMPLETELY unrelated projects. I place each published project into each respective folder. Nothing fancy.
  2. Each project only has 1 HomeController.

Can someone confirm this is the problem?

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Here is another scenario where you might confront this error. If you rename your project so that the file name of the assembly changes, it's possible for you to have two versions of your ASP.NET assembly, which will reproduce this error.

The solution is to go to your bin folder and delete the old dlls. (I tried "Rebuild Project", but that didn't delete 'em, so do make sure to check bin to ensure they're gone)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...