title: How to make ASP.NET Routing escape route values?
body: <p>I have an ASP.NET MVC site where I want routes like <code>/{controller}/{id}/{action}/{date}</code>, where "date" is the <em>mm/dd/yyyy</em> portion of a date/time. (I'm dealing with time-dimensioned data, so I need both an ID and a point in time to do most operations)</p>
  
  <p>The route for this is simple:</p>
  
  <pre><code>routes.MapRoute(
      "TimeDimensionedRoute",
      "{controller}/{id}/{action}/{date}",
      new { controller = "Iteration", action = "Index", id = String.Empty, date = String.Empty }
  );
  </code></pre>
  
  <p>This route correctly maps "<strong>/Foo/100/Edit/01%2F21%2F2010</strong>" to the desired action. <strong>Update: this is incorrect. This is NOT routed correctly, I was mistaken. See the related question linked in the accepted answer.</strong></p>
  
  <p>My problem is that when I use Html.ActionLink() to generate a link for this route, it <strong>does not URL-encode the date</strong> and I end up with invalid URLs such as "<strong>/Foo/100/Edit/01/21/2010</strong>".</p>
  
  <p>Is there any way to get the routing infrastructure to encode the values for me? It seems wrong that I have to manually URL-encode data that I pass to the HTML helpers.</p>