title: Routing based on query string parameter name
body: <p>I'm trying to configure routing in my MVC4 WebAPI project.</p>
  
  <p>I want to be able to search for products based on their name or their type like so:</p>
  
  <p><code>/api/products?name=WidgetX</code> - returns all products named WidgetX
  <code>/api/products?type=gadget</code> - returns all products of type gadget</p>
  
  <p>The routes are configured like this:</p>
  
  <pre><code>config.Routes.MapHttpRoute(
      name: "Get by name",
      routeTemplate: "api/products/{name}",
      defaults: new { controller = "ProductSearchApi", action = "GetProductsByName", name = string.Empty }
  );
  
  config.Routes.MapHttpRoute(
      name: "Get by type",
      routeTemplate: "api/products/{type}",
      defaults: new { controller = "ProductSearchApi", action = "GetProductsByType", type = string.Empty }
  );
  </code></pre>
  
  <p>The problem is that the name of the query string parameter seems to be ignored so the first route is always the one used, regardless the name of the query string parameter.
  How can I modify my route to get it right?</p>