title: Web API Routes to support both GUID and integer IDs
body: <p>How can I support <code>GET</code> routes for both GUID and integer? I realize GUIDs are not ideal, but it is what it is for now. I'm wanting to add support for integers to make it easier for users to remember and communicate what <em>should be</em> unique "keys."</p>
  
  <p>Example routes:</p>
  
  <pre><code>testcases/9D9A691A-AE95-45A4-A423-08DD1A69D0D1   
  testcases/1234
  </code></pre>
  
  <p>My <code>WebApiConfig</code>:</p>
  
  <pre><code>public static void Register(HttpConfiguration config)
  {
      config.MapHttpAttributeRoutes();
      var routes = config.Routes;
  
      routes.MapHttpRoute("DefaultApiWithAction", 
          "Api/{controller}/{action}");
  
      routes.MapHttpRoute("DefaultApiWithKey",
          "Api/{controller}/{key}",
          new { action = "Get" },
          new { httpMethod = new HttpMethodConstraint(HttpMethod.Get), key = @"^\d+$" });
  
      routes.MapHttpRoute("DefaultApiWithId", 
          "Api/{controller}/{id}", 
          new { action = "Get" }, 
          new { httpMethod = new HttpMethodConstraint(HttpMethod.Get) });
  
      routes.MapHttpRoute("DefaultApiGet", 
          "Api/{controller}", 
          new { action = "Get" }, 
          new { httpMethod = new HttpMethodConstraint(HttpMethod.Get) });
  
      routes.MapHttpRoute("DefaultApiPost", 
          "Api/{controller}", 
          new { action = "Post" }, 
          new { httpMethod = new HttpMethodConstraint(HttpMethod.Post) });
  }
  </code></pre>
  
  <p>My controller (method signatures only):</p>
  
  <pre><code>[RoutePrefix("Api/TestCases")]
  public class TestCasesController : PlanControllerBase
  {
      [Route("")]
      public OperationResult&lt;IEnumerable&lt;TestCaseDTO&gt;&gt; Get([FromUri] TestCaseRequest request)
  
      [Route("{id}")]
      [HttpGet]
      public OperationResult&lt;TestCaseDTO&gt; Get(Guid id)
  
      [Route("{key}")]
      [HttpGet]
      public OperationResult&lt;TestCaseDTO&gt; Get(int key)
  
      ...
  }
  </code></pre>
  
  <p>I'm getting an <em>Internal Server Error</em> when I attempt to call the resource using the integer. Any help is appreciated!</p>