title: ASP.NET routing with optional URL segments
body: <p>I'm working on an ASP.NET MVC task list and I'd like to get fancy with the URL routing when filtering the list. I have an action method defined like this:</p>
  
  <pre><code>public ActionResult List(int categoryID, bool showCompleted, TaskFilter filter);
  
  enum TaskFilter { MyTasks, MyDepartmentTasks, AllTasks }
  </code></pre>
  
  <p>I want my URLs to look like this:</p>
  
  <pre><code>/Tasks/Category4/MyTasks/ShowCompleted/
  /Tasks/Category4/MyDepartment
  /Tasks/Category4/
  </code></pre>
  
  <p>The <code>Category#</code> segment will always be present. I'd like the <code>MyTasks|MyDepartment|AllTasks</code> segment to be optional, defaulting to <code>AllTasks</code> if absent. I'd also like <code>ShowCompleted</code> to be optional, defaulting to false.</p>
  
  <p>Is this sort of routing possible, or am I going to have to fall back and just use querystring parameters?</p>
  
  <p>Followup/extra credit question: What if I also wanted a fourth parameter on the action method to filter by task due date that looked like <code>Today|Day2Through10</code> (default <code>Today</code> if absent)?</p>