title: MVC & WebAPI "Multiple types were found that match the controller named..."
body: <p>I have a routing problem with MVC and WebAPI controllers.</p>
  
  <p>The error is:</p>
  
  <blockquote>
    <p>Multiple types were found that match the controller named 'Log'. This
    can happen if the route that services this request
    ('api/{controller}/{action}/{id}') found multiple controllers defined
    with the same name but differing namespaces, which is not supported.
    The request for 'Log' has found the following matching controllers:
    MyNamespace.Controllers.LogController
    MyNamespace.Controllers.WebAPI.LogController</p>
  </blockquote>
  
  <p>My routing is simple:</p>
  
  <pre><code>public static void RegisterRoutes(RouteCollection routes)
  {
      routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
  
      routes.MapRoute(
          name: "Default",
          url: "{controller}/{action}/{id}",
          defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
      );
  }
  </code></pre>
  
  <p>I have tried adding an additional route for WebAPI like:</p>
  
  <pre><code>routes.MapHttpRoute(
      name: "API",
      routeTemplate: "api/{controller}/{action}/{id}",
      defaults: new { id = RouteParameter.Optional }
  );
  </code></pre>
  
  <p>Along with adding a namespace for the MVC route:</p>
  
  <pre><code>namespaces: new[] { "MyNamespace.Controllers" }
  </code></pre>
  
  <p>But I still receive the same error. I cannot see a way to specify the namespace for the WebAPI route.</p>
  
  <p>There is a <a href="https://stackoverflow.com/questions/7842293/multiple-types-were-found-that-match-the-controller-named-home/7842369">well-upvoted duplicate</a> but that is specifically about MVC controllers. The answers talk about adding a namespace as above, which has not helped here. In my case the routing to the MVC controller works fine, and it is only the WebAPI controller where I have the problem.</p>
  
  <p>The strange thing is, all my other WebAPI controllers have the same name as MVC controllers but this is the only one where I run into the error.</p>