I currently have 2 projects in same folder. Main
Multiple types were found that match the controller named Account. 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 Account
has found the following matching controllers:
Project1.Controllers.AccountController
Project2.Controllers.AccountController
I using Foundation 4. Thanks advance
One should be of type Controller, and the other ApiController, then they can both exist with the same name.
The Controller class exposes Request and Response properties that can be accessed in an action method.
you need to use the version with this signature
public static Route MapRoute(
this RouteCollection routes,
string name,
string url,
Object defaults,
string[] namespaces )
To make it work just set up two almost identical routes - one which includes the project1 for the namespaces parameter and then a second identical version but use project2 in the namespaces parameter. That said, it would generally be less confusing, to use different names if you can...
routes.MapRoute(
name: "Default_Project1",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional,
namespaces: new string[] { "Project1" } }
);
routes.MapRoute(
name: "Default_Project2",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional,
namespaces: new string[] { "Project2" }
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With