我想使用我的ActionLink创建
一个像/?name = Macbeth& year = 2011的URL,我已经尝试过这样:
<%= Html.ActionLink("View Details","Details","Performances",new { name = item.show },new { year = item.year })%>
但它不工作。我如何做到这一点?
您使用的重载使年值在
链接的html
属性中结束(检查渲染源)。
过载签名看起来像这样:
MvcHtmlString HtmlHelper.ActionLink(
string linkText,string actionName,string controllerName,object routeValues,object htmlAttributes
)
你需要把你的路由值放入RouteValues字典,像这样:
Html.ActionLink(
"View Details",new { name = item.show,year = item.year },null
)