开发者

auto add route parameter to url

i have 2 urls on one page: http://host/home/list and http://host/home/list/1. if i click on second url then first url renders with param 1, so url1 equals ulr2 (url1 = http://host/home/list/1 and url2=http://host/home/list/1)

i use such code

 <%= Html.ActionLink("link", "DesignerFiles", "Home", null, null)%> url1

<%= Html.ActionLink("link", "Des开发者_如何学JAVAignerFiles", "Home", new { id = 1} , null)%> url2

what the problem?


I had a simliar issue with sub level and tertiary navigation elements. IE - a link that should go to /Home/About from the /Home/About/People would append /People to the first link. I used the following method to get this to work correctly:

<%= Html.ActionLink("Link", "About", "Home", new with {.section = nothing}, nothing%>
<%=Html.ActionLink("Link2", "About", "Home", new with {.section = "People"}, nothing%>

That seemed to force the ActionLink to not include the additional parameter that was in the current context of my view. Side note, I changed the dafault {controller}/{action}/{id} to {controller}/{action}/{section} - which is why you see section in my route values.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜