title: Asp.Net Web API Routing - Required QueryString Parameters
body: <p>How can I require a querystring for certain routes in an Asp.Net Web API?</p>
  
  <p>Controllers:</p>
  
  <pre><code>public class AppleController : ApiController
  {
      public string Get() { return "hello"; }
      public string GetString(string x) { return "hello " + x; }
  }
  
  public class BananaController : ApiController
  {
      public string Get() { return "goodbye"; }
      public string GetInt(int y) { return "goodbye number " + y; }
  }
  </code></pre>
  
  <p>Desired routes:</p>
  
  <pre><code>/apple        --&gt; AppleController  --&gt; Get()
  /apple?x=foo  --&gt; AppleController  --&gt; Get(x)
  /banana       --&gt; BananaController --&gt; Get()
  /banana?y=123 --&gt; BananaController --&gt; Get(y)
  </code></pre>