开发者

How do I get the route user\22\edit in ASP.NET MVC

开发者 https://www.devze.com 2022-12-20 02:29 出处:网络
So I have my route setup for accepting something like 开发者_StackOverflow中文版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

So I have my route setup for accepting something like 开发者_StackOverflow中文版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


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号