我在用户模块的主页面中使用了actionlink。我想将当前网址的eventid(在所有视图中)作为路由值传递给actionlink。但我使用以下代码,
<%=Html.ActionLink("Create Account", "UserRegistration",
new { eventid = ViewContext.RouteData.Values["id"] })%>
但它不会检索网址的ID。
我的网址是以下格式,
http://localhost:12905/User/User/Order?eventID=2
这里eventID = 2对于所有视图都是通用的。所以我想将此eventID作为路由值发送到actionlink。 提前谢谢,
答案 0 :(得分:1)
在ActionLink中不应该是“eventId”而不是“id”:
<%= Html.ActionLink(... ViewContext.RouteData.Values["eventId"] })%>