Sunday, January 2, 2011

[Web-Dev]– ASP.NET MVC error: Multiple types were found that match the controller named CONTROLLER_NAME

I’ve been learning Microsoft’s ASP.NET MVC framework (loving it so far, a huge improvement over web forms!) and came across this error which others may run into at some point.

I created my project in visual studio, and then decided to rename it to change the namespace (ie it used to be project name, and now its company.projectname). This caused me some problems with the routing, after changing the namespace of my controller, it still seemed to detect the old namespace as well as the new one, which was very strange given the old version should not exist anymore. As a result, it didn’t know which controller to use.

I found the problem was to do with an old version of my web application DLL still being present in the bin directory, as the namespace changed, it didn’t get overwritten, so cassini detects this. Cleaning out the bin directory fixes the problem.

There are a couple of different reasons why you could get this error, so if this doesn’t solve it for you, have a look at this Stack Overflow post.

1 comment:

Anonymous said...

I too faced the same problem and used the following method to solve it.
AccountController is automatically generated by the ASP.NET MVC Visual Studio template. It is located in Controllers\AccountController.cs. Try searching for it in the project and delete it.