views:

1017

answers:

3

I receive the following error when trying to run my ASP.NET MVC application:

The request for 'Account' has found the following matching controllers: uqs.Controllers.Admin.AccountController MvcApplication1.Controllers.AccountController

I searched the project for MvcApplication1.Controllers.AccountController to remove it, but I can't find a match.

I try to registered a route to fix it:

 routes.MapRoute(
     "LogAccount", // Route name
     "{controller}/{action}/{id}", // URL with parameters
     new { controller = "Account", action = "LogOn", id = "" },
     new string[] { "uqs.Controllers.Admin" } // Parameter defaults
 );

but that didn't solve it.

Multiple types were found that match the controller named 'Account'.

How I can fix this problem?

A: 

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.

Darin Dimitrov
sorry, may be i can't explain my problem. but, I know where located AccountController. but I haven't namespace with name MvcApplication1.Controllers.AccountController, i rename it to uqs.Controllers.Admin. and, trying to run my web app.
loviji
+3  A: 

You can't have more than one controller named Account in your application, even in different namespaces.

You have to have these controllers split up by Area (a feature in ASP.NET MVC 2).

If you conduct a Find for AccountController you'll find all controllers named Account in your application; and move them off into different Areas if you want both of them, or delete one.

George Stocker
Are you sure? I have two controllers in different namespaces, one inheriting from the other, and I do not use Areas. Setting the namespace in the MapRoute (just like lovjii does above) fixed the same exact error message. Is the difference that my controllers inherit from each other?
Oskar Austegard
+6  A: 

If you refactor your project and change the default Namespace and Assembly from "MVCApplication1" to "uqs", you may end up with 2 assemblies in your bin directory (the new one and the old one). You can get this error because the AccountController is in both assemblies.

Clean your bin directory of the old MVCApplication1.dll.

Parched Squid