Take the 2-minute tour ×

The Html.ActionLink

<li> ${Html.ActionLink<HomeController>(c => c.Edit(ViewData.Model.Id, ViewData.Model.Title), "Edit")} </li>

When created as html shows the URL to be Edit/5006?title=One . How do I change this to a pretty URL like Edit/5006/One ?

My Edit Action method is

public ActionResult Edit(int id, string title) 
share|improve this question
add comment

3 Answers

up vote 2 down vote accepted

You need to have a route setup:

        controller = "Home", 
        action = "Edit", 
        id = UrlParameter.Optional,
        title = UrlParameter.Optional
share|improve this answer
add comment

It is not depends on the function stamp, but it depends on the routing configuration.

routes.MapRoute("Edit",                                         // Route name
        "{controller}/{action}/{id}/{title}",                   // URL with parameters 
share|improve this answer
add comment

Take a look at the first answer to this question: http://stackoverflow.com/questions/200476/html-actionlink-method

The important point is that you have to make sure you're using the right overload for ActionLink().

share|improve this answer
add comment

Your Answer


