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:
SomeNamespace.Web.Controllers.HomeController
SomeNamespace.Web.Areas.Admin.Controllers.HomeController
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:
ControllerBuilder.Current.DefaultNamespaces.Add("DefaultNamespace.Controllers");
Post being viewed right now
Item date: 22.08.2009
Views: 1438
Item date: 13.12.2009
Views: 934
Item date: 03.01.2009
Views: 1068
Item date: 03.01.2009
Views: 2157
Item date: 06.02.2009
Views: 1159
Item date: 11.01.2012
Views: 192
Item date: 03.01.2009
Views: 327
Item date: 01.01.2008
Views: 571
Item date: 09.03.2009
Views: 523
Item date: 26.09.2009
Views: 511