title: ASP.NET MVC: Route with optional parameter, but if supplied, must match \d+
body: <p>I'm trying to write a route with a nullable int in it. It should be possible to go to both <code>/profile/</code> but also <code>/profile/\d+</code>.</p>
  
  <pre><code>routes.MapRoute("ProfileDetails", "profile/{userId}",
                  new {controller = "Profile",
                       action = "Details",
                       userId = UrlParameter.Optional},
                  new {userId = @"\d+"});
  </code></pre>
  
  <p>As you can see, I say that <code>userId</code> is optional but also that it should match the regular expression <code>\d+</code>. This does not work and I see why.</p>
  
  <p>But how would I construct a route that matches just <code>/profile/</code> but also <code>/profile/</code> followed by a number?</p>