title: GetControllerMapping returning an empty collection in WebApi2
body: <p>I am working on creating a REST API.</p>
  
  <p>I put something simple together that works using WebApi.</p>
  
  <p>Then I discovered that I couldn't call it from outside of my domain, so I looked up what to do about that and found <a href="http://www.asp.net/web-api/overview/security/enabling-cross-origin-requests-in-web-api#enable-cors" rel="nofollow">this article on ASP.net</a>. The <code>config.EnableCors()</code> method doesn't appear to be available in WebApi but the article was written for WebApi2, so I uninstalled all of the packages and replaced them with their v2 counterparts.</p>
  
  <p>Before making any CORS changes, I tried testing the API. I kept getting a 404 error. Debugging revealed that I am getting to the API OK, the problem is the call to <code>GetControllerMapping()</code>. With the WebApi v1 packages in place, this returned a collection of 5 controller. Having <em>only</em> replaced them with the v2 versions, the call returns an empty collection.</p>
  
  <p>The Controller Section method is shown below...</p>
  
  <pre><code>    public override HttpControllerDescriptor SelectController(HttpRequestMessage request)
      {
          var controllers = GetControllerMapping(); // &lt;=== This is the line that returns an empty collection
          var routeData = request.GetRouteData();
          var controllerName = (string)routeData.Values["controller"];
          HttpControllerDescriptor result = null;
  
          if (!controllers.TryGetValue(controllerName, out result))
          {
              string version;
              if (!GetVersionFromMediaType(request, out version))
              {
                  if (!GetVersionFromAcceptHeaderVersion(request, out version))
                  {
                      if (!GetVersionFromHeader(request, out version))
                      {
                          if (!GetVersionFromQueryString(request, out version))
                          {
                              version = V_LATEST;
                          }
                      }
                  }
              }
  
              HttpControllerDescriptor versionedDescriptor;
  
              var newName = string.Concat(controllerName, "V", version);
              if (controllers.TryGetValue(newName, out versionedDescriptor))
              {
                  result = versionedDescriptor;
              }
          }
  
          return result;
      }
  </code></pre>
  
  <p>The various "GetVersion*" methods just return true/false depending on if they have found the relevant data and put tat data in the <code>out version</code> parameter.</p>
  
  <p>FWIW, I can see the service registering the routes when it starts up.</p>
  
  <p>Clearly, I've missed something but, so far, I've not found any documentation that might explain what it is.</p>
  
  <p>Can anyone offer any suggestions?</p>