Asp.Net MVC: How do I get Html.ActionLink to render integer values properly?

I have an asp.net mvc application with a course comparable 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 activity method trademark looks like:

public ActionResult Detail(int year, int month, int day, string friendlyName)
{ // Implementation... }

In my sight, 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 created with ActionLink functions, it makes use of question string variables as opposed to URL revising.

As an example, it would certainly generate/ blog/detail/my - slug?year = 2008&month = 7&day = 5 as opposed to/ blog/detail/2008/07/05/ my - slug

Is there a means to get the common variation of ActionLink to effectively pad the integer values to make sure that the url appears as anticipated?

Many thanks

Jim

5
2022-07-25 17:42:35
Source Share
Answers: 0