Hey all,
I have an asp.net mvc application with a route similar to:
routes.MapRoute("Blog",
"{controller}/{action}/{year}/{month}/{day}/{friendlyName}",
new { controller = "Blog", action = "Index", id = "", friendlyName="" },
new { controller = @"[^\.]*",
year = @"\d{4}",
month = @"\d{2}",
day = @"\d{2}" }
);
My controller action method signature looks like:
public ActionResult Detail(int year, int month, int day, string friendlyName)
{ // Implementation... }
In my view, I'm doing something like:
<%= Html.ActionLink<BlogController>(item => item.Detail(blog.PostedOn.Year, blog.PostedOn.Month, blog.PostedOn.Day, blog.Slug), blog.Title) %>
While the url that is generated with ActionLink works, it uses query string variables rather than URL rewriting.
For example, it would produce /blog/detail/my-slug?year=2008&month=7&day=5 instead of /blog/detail/2008/07/05/my-slug
Is there a way to get the generic version of ActionLink to properly pad the integer values so that the url comes out as expected?
Thanks
Jim