MVC – The dreaded "Multiple types were found that match the controller named"

 

So I have spent time on a project involving MVC and have this dreaded issue that many users seem to have with the routing once you change any of the defaults (for instance areas and namespaces). The error is "Multiple types were found that match the controller named"

After a lot of banging my head against the wall, crying and almost throwing my laptop out the window, i came across a web site by <a href ="http://www.johnplummer.com/code/mvc-multiple-types-were-found-that-match-the-controller-named-home.html/comment-page-1#comment-33365">John Plummer</a> which mentioned that VS likes to keep your original executable
from when you first created the project and instead of renaming the executable, it just creates another one. This is one of the usual major issues that this error can created.

Another issue that can cause this is the changing of namespaces and adding areas. If you add the new string to the end of your area registration page like below, it will route your area’s to the correct controllers:

new { action = "Index", id = UrlParameter.Optional }, new string[] { "CISE.UserInterface.Controllers"}

Hope this helps others!!

Advertisements

About Gregg Coleman

I am Senior-level Software Engineer working primarily these days with .NET. I have a good working knowledge of ASP.NET MVC, Web Forms, WCF web services and Windows Services. I spend much of my time in the Web Services (SOAP and REST) world in my current job designing and implementing various SOA architectures. I have been in the software engineering industry for about 6 years now and will not now nor ever consider myself an "expert" in programming because there is always so much to learn. My favorite thing about designing software is there are always new emerging technologies and something to learn every day! My current job has me spending much of my job on the bleeding edge of technologies and changing gears all the time, so I'm never bored and always challenged. On my spare time I enjoy weight training, reading and venturing to new places near by. Of course programing and learning new technologies are another hobby of mine.
This entry was posted in ASP.NET, C# and tagged , , , . Bookmark the permalink.

3 Responses to MVC – The dreaded "Multiple types were found that match the controller named"

  1. Raul Vejar says:

    Thanks, you pointed me in the right direction, although it was simpler to me to just delete the old dlls that VS refused to “clean”

  2. Pingback: Namespace changes with Silverlight 8.1 | Object Reference Hell

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s