title: MVC 5 Routing and Optional Parameters
body: <p>I have the following controller and route definition</p>
  
  <pre class="lang-c# prettyprint-override"><code>[System.Web.Mvc.Route("users/{firstName?}/{lastName?}/{emailAddress?}/{pageSize:int=10}/{pageNumber:int=1}", Name = RouteNames.User_Listing)]
  public ActionResult Index(string firstName = null, string lastName = null, string emailAddress = null, int pageNumber = 1, int pageSize = 10)
  </code></pre>
  
  <p>What I want is for any of these to be undefined or defined and so all these would be valid</p>
  
  <pre><code>users/first/last/email
  users/last/email/30/2
  users/last/1
  users
  </code></pre>
  
  <p>Problem is, how does MVC know which of the parameters has been specified?  It doesn't!</p>
  
  <p>When I have this link</p>
  
  <pre><code>@Html.RouteLink("Maintain Users", RouteNames.User_Listing)
  </code></pre>
  
  <p>it doesn't navigate to this action method.  What do I do?</p>