Back to blog

Fixing ‘multiple types were found that match the controller named’

October 12, 2010 - Posted in ASP.NET MVC Posted by:

ASP.NET MVC introduced the concept of ‘areas’ within a web app.
They’re a great way to split a large app into different sections that handle different logic, for example you might have an admin area that has some authorization and handles all of the back end content management for the app. You can think of them almost as ‘sub-projects’, as they have their own controllers and views.

It isn’t unlikely that you might have the default controller called Home in the root, and also another controller called Home in a separate area.
However, because of the fact that MVC works as pre-compiled web application (rather than a web site), all the controllers get compiled into the assembly and you get the following 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 request for ‘Home’ has found the following matching controllers:

So, despite the fact that the controllers are in different namespaces, the app doesn’t know which one to use. Fortunately, there is an easy fix to tell MVC which namespace to use as the default. Open the global.asax.cs file from the root, and find the Application_Start method. It should have two lines in at the moment (AreaRegistration.RegisterAllAreas(); and RegisterRoutes(RouteTable.Routes);). Simply add the following line after these, replacing the namespace in quotes with the namespace of your controllers:



Uday Shastri 7 years ago

Saved my lot of time.

Muhammad 7 years ago

Thnx bro ,, It really helped me to solve the routing issue .

streetspirit 7 years ago

Thx man, gotcha

Rich Hosek 7 years ago

Okay, but then when I try to use the following route:

I do not get my Home/Index controller/action even though I have

new { action = "Index", id = UrlParameter.Optional }

in my AreaNameAreaRegistration.cs file.

Ian Routledge 7 years ago

Hi Rich, try

new { controller = "Home", action = "Index", id = UrlParameter.Optional }

Aaron Freeland 7 years ago

Worked great…much appreciated =)

Tom Wayson 7 years ago

Thanks. Solved my problem (FYI – on MVC 3).

Saeed Neamati 6 years ago

I got this error because I changed the namespace of the entire project. However, I don’t have any areas, and there is really no conflict in areas here. What could be the reason?

Ian Routledge 6 years ago

Hi Saeed

This will be because the old compiled dll will still be in the bin folder so the runtime will be picking up both the new dll and the old dll. Simply clean the solution in visual studio or manually go in the bin folder and delete the old dll.


Andrej 6 years ago

Worked like a charm. Thanks a lot, man.

Jon 6 years ago

Nice tip, and I was on the point of using your advice when I found something similar at
– you can also specify a namespaces “search list” in the route itself. I had the same duplicate “Home” controller issue but solved it with:

"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional }, // Parameter defaults
new string [] { "My_App_Name.Controllers" }


Ian Routledge 6 years ago

Ah yes, so you can. Good stuff, thanks for contributing.

Leonard Iilonga 6 years ago

Worked perfectly. Thanks a million.

Hatef 6 years ago

Thank you very much ..

Adam 6 years ago

This fixed my problem, thank you for taking the time to write this blog article. Legend :D

Navtej Singh 6 years ago

Saved a lot of time…
gOOd information