I have an ASP.NET MVC site where I want routes like /{controller}/{id}/{action}/{date}
, where "date" is the mm/dd/yyyy 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)
The route for this is simple:
routes.MapRoute(
"TimeDimensionedRoute",
"{controller}/{id}/{action}/{date}",
new { controller = "Iteration", action = "Index", id = String.Empty, date = String.Empty }
);
This route correctly maps "/Foo/100/Edit/01%2F21%2F2010" to the desired action. Update: this is incorrect. This is NOT routed correctly, I was mistaken. See the related question linked in the accepted answer.
My problem is that when I use Html.ActionLink() to generate a link for this route, it does not URL-encode the date and I end up with invalid URLs such as "/Foo/100/Edit/01/21/2010".
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.