title: ASP.NET Web API - How to Create Different Action Methods for Routes "product/id" and "product?someOtherId=10"
body: <p>With Web API, I need to redirect the following two Restful routes to two different action methods:</p>
  
  <p><strong>/products/2</strong> -> Get info for product id 2</p>
  
  <p><strong>/products?someOptionalId=456</strong> -> Get info for all products. Use someOptionalId as a filter if provided.</p>
  
  <p>Unfortunately using the standard routing and model binding scheme, since both URLs point to the same <strong>products controller</strong> and have <strong>one id as a parameter</strong>, I either run into a compile time issue creating two Get methods with same int parameter, or a run time issue with MVC not able to pick a particular action method</p>
  
  <p><strong>Compile time error</strong></p>
  
  <pre><code>public IQueryable&lt;Product&gt; Get(int someOptionalIdQs)
  {
  
  }
  
  public Product Get(int id)
  {
  
  }
  </code></pre>
  
  <p><strong>Run time error (Note hack to use a string for someOptionalIdQs and then convert to int)</strong> </p>
  
  <pre><code>public IQueryable&lt;Product&gt; Get(string someOptionalIdQs)
  {
  
  }
  
  public Product Get(int id)
  {
  
  }
  </code></pre>
  
  <p>Please suggest a fix ideally without having to make any routing config changes given that I would like to keep the routing as clean as possible. Thanks.</p>