views:

97

answers:

3

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) 
A: 

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().

Dave Swersky
+1  A: 

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 
        new { controller = "Home", action = "Index", id = "" }  // Parameter defaults 
); 
Mendy
+2  A: 

You need to have a route setup:

routes.MapRoute(
    "DefaultWithTitle",
    "{controller}/{action}/{id}/{title}",
    new 
    { 
        controller = "Home", 
        action = "Edit", 
        id = UrlParameter.Optional,
        title = UrlParameter.Optional
    }
);
Darin Dimitrov