title: ASP.NET route passing string value
body: <p>I'm trying to have a page on an ASP.NET MVC based web site where one page allows selecting by username instead of ID. I would have thought the route needs to be something like:</p>
  
  <pre><code>routes.MapRoute(
    "CustomerView", "Customer/Details/{username}",
    new { username = "" }
  );
  
  routes.MapRoute(
    "Default", "{controller}/{action}/{id}",
    new { controller = "Home", action = "Index", id = "0" }
  );
  </code></pre>
  
  <p>but whenever I use HTML.Actionlink I get <a href="http://mysite.com/Customer/Details?username=valuehere" rel="nofollow noreferrer">http://mysite.com/Customer/Details?username=valuehere</a> . I considered a generic route like:</p>
  
  <pre><code>routes.MapRoute(
    "CustomerView", "Customer/Details/{username}",
    new { controller="Customer", action = "Details", username = "" }
  );
  </code></pre>
  
  <p>but I imagine it would cause more problems when it mistakes which route should be applied of the two.</p>