title: Optional route parameters and action selection
body: <p>I use the default route definition:</p>
  
  <pre><code>{controller}/{action}/{id}
  </code></pre>
  
  <p>where <code>id = UrlParameter.Optional</code>. As much as I understand it this means when <code>id</code> is not being part of the URL this route value will not exists in the <code>RouteValues</code> dictionary.</p>
  
  <p>So this also seems perfectly possible (both GET):</p>
  
  <pre><code>public ActionResult Index() { ... } // handle URLs: controller/action
  
  public ActionResult Index(int id) { ... } // handle URLs: controller/action/id
  </code></pre>
  
  <p>When <code>id</code> is missing the first action would be executed, but when <code>id</code> is present, the second one would execute. Fine, but <strong>it doesn't work</strong>. It can't resolve actions.</p>
  
  <p><strong>How can I accomplish this?</strong></p>
  
  <p>I'm thinking of writing a custom action method selector attribute like:</p>
  
  <pre><code>[RequiresRouteValue(string valueName)]
  </code></pre>
  
  <p>This would make it possible to use this kind of action methods. But is this the only way of doing it?<br>
  <strong>Is there something built-in I can hang on to?</strong></p>