By distinguishing controller namespace
When the controller duplicate names, there are two ways to avoid access exceptions:
Namespace 1. The modified controller, routing configuration, when accessing a namespace added
2. Change the name of the controller, modifying access path
The second looks relatively easy. But first way is also the way to learn about:
Find webapiconfig routing configuration folder in appstart
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
config.MapHttpAttributeRoutes();
config.Services.Replace(typeof(IHttpControllerSelector), new NamespaceHttpControllerSelector(config));
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{namespace}/{controller}/{action}"
);
}
}
Access methods:
API / namespace / name of the controller / method name