tags:

views:

33

answers:

2

Hi,

So I have my route setup for accepting something like user\22\edit where 22 is the ID of the user we are editing. I can type this into the URL bar in my browser and things are good to go. My questions though is how can an ActionLink on a view to have that same URL structure when clicked?

Thanks

+1  A: 

<%= Html.ActionLink("Edit", "edit", new { id = 22 }) %>

see http://msdn.microsoft.com/en-us/library/system.web.mvc.html.linkextensions.actionlink.aspx

moi_meme
A: 

Your problem is with your routes. The html actionlink helper will choose the first route that can match the values you supply. If you add a route something like this:

"User/{id}/Edit", new { controller = "User", action = "Edit", id = "" }

Before the default route, and any other route that might be able to match your values and your good to go.

Mattias Jakobsson