All about Programming and Sourcecode

Multiple types were found that match the controller Error in ASP.NET MVC

There are times when you get the error similar to the below message when you type the URL

“Multiple types were found that match the controller named ‘Employee’. This can happen if the route that services this request (‘Abundantcode/{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 ‘Employee’ has found the following matching controllers:

MvcApplication1.Controllers.EmployeeController

MvcApplication2.Controllers.EmployeeController”

Multiple types were found that match the controller Error in ASP.NET MVC

If the above error message is observed, it clearly states that the reason for the error is the Multiple Controller Name and Action Method defined in different Namespaces.

One way to resolve this error is to make sure that the controller name is unique. The other simple option is to specify the preference of the Namespace to be used in the MapRoute method of the RouteConfig file.

0saves
If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.
 
Comments

No comments yet.

Leave a Reply