title: WebApi routes with same routeTemplate with version constraint
body: <p>I'm building an api using WebAPI. What I'm shooting for is creating an external library per version of the API which the WebAPI app will query when registering its routes in <code>WebApiConfig</code></p>
  
  <p><strong>Example:</strong> <code>Api.v1</code> and <code>Api.v2</code></p>
  
  <hr>
  
  <p>They will share similar functionality but based on <code>version</code> passed in the header it will choose the proper API Version:</p>
  
  <p><code>/{controller}/{action}</code> - <code>HTTP-HEADER: version=1</code> maps to <code>Api.v1.Controller/Action</code></p>
  
  <p><code>/{controller}/{action}</code> - <code>HTTP-HEADER: version=2</code> maps to <code>Api.v2.Controller/Action</code></p>
  
  <hr>
  
  <p>The goal is to avoid prefixing <code>/{ver}/{controller}/{action}</code>. I know that having <code>routeTemplates</code> with the same value is not supported, but I thought I could bind the route to a specific namespace and a constraint might help settle which is matched:</p>
  
  <pre><code>namespace Api.v1
  {
      public static class Routing
      {
          public static void MapRoutes(HttpConfiguration config)
          {
              IHttpRoute r = config.Routes.MapHttpRoute(
                  name: "",
                  routeTemplate: "{controller}/{action}/{id}",
                  defaults: new 
                  {
                      id = RouteParameter.Optional, 
                      namespaces = new string[] { "Api.v1.Controllers" } 
                  },
                  constraints: new VersionConstraint(2)
              );
          }
      }
  }
  </code></pre>
  
  <hr>
  
  <pre><code>public class VersionConstraint : IRouteConstraint
  {
      int _version;
      public VersionConstraint(int version)
      {
          _version = version;
      }
  
      public bool Match(
          HttpContextBase httpContext, 
          Route route, 
          string parameterName, 
          RouteValueDictionary values, 
          RouteDirection routeDirection)
      {
          int version;
          int.TryParse(httpContext.Request.Headers["version"], out version);
          return version == _version;
      }
  }
  </code></pre>
  
  <p>Attempting to inject the <code>namespaces</code> for each route hasn't really helped either. The <code>DataTokens</code> property is null and readonly.</p>
  
  <hr>
  
  <p><strong>Any idea how to do what I'm doing? Any way to have the same route map to different controllers of the same name but with different functionality and namespace?</strong></p>