34

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

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:

oldns.Controllers.HomeController

newns.Controllers.HomeController

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

Community
  • 1
  • 1
Hypnovirus
  • 1,555
  • 1
  • 10
  • 21

1 Answers1

96

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

Hypnovirus
  • 1,555
  • 1
  • 10
  • 21
  • 4
    Thanks for finding this, saved me from struggling with this. From what I can tell performing a Clean does not delete everything, and if there are ever problems compiling you should close the project and delete all of the contents of your project's bin folder and then open the project and compile / test again. +1 – Dave May 24 '13 at 23:15
  • Thank You man, I renamed the project and got into this problem. your suggestion solved it - Thanks – VivekDev Nov 04 '14 at 07:17
  • It was not deleting min when cleaning because along with the namespace, I changed the name of the assembly. It cleaned everything but the assembly with the old name. So it was apparently scanning the old assembly for controllers at runtime as well. – xr280xr May 29 '20 at 03:58