title: Routing in ASP NET Web API - For different versions of an API
body: <p>I am reading about <code>Attribute Routing in Web API 2</code> from <a href="http://www.asp.net/web-api/overview/web-api-routing-and-actions/attribute-routing-in-web-api-2" rel="noreferrer">here</a></p>
  
  <p>The article says, </p>
  
  <pre><code>Here are some other patterns that attribute routing makes easy.
  
  API versioning
  
  In this example, “/api/v1/products” would be routed to a different controller than “/api/v2/products”.
  
  /api/v1/products
  /api/v2/products
  </code></pre>
  
  <p>How come?</p>
  
  <p>EDIT: I would do this in <strong><em>Normal Routing:</em></strong></p>
  
  <pre><code>public static class WebApiConfig
  {
      public static void Register(HttpConfiguration config)
      {
           config.Routes.MapHttpRoute(
              name: "DefaultApi",
              routeTemplate: "api/v2/products",
              defaults: new { controller = V2_Products }
          );
  
          config.Routes.MapHttpRoute(
              name: "DefaultApi",
              routeTemplate: "api/v1/products",
              defaults: new { controller = V1_Products }
          );
      }
  }
  </code></pre>
  
  <p>Could anyone explain me how to do this in <code>Attribute Routing</code> way ? And how come using <code>Attribute routing</code> is easier and convenient for this example (according to the article) ?</p>