有没有办法将Dictionary<string, string>
传递给Html.ActionLink()
?
var myDictionary = new Dictionary<string, string> { { "serviceId", "2342" } }
我试过这样做:
Html.ActionLink("Text here", "Action","Controller", myDictionary, null)
但这不起作用
答案 0 :(得分:3)
您可以使用以下overload:
<%= Html.ActionLink(
"Text here",
"Action",
"Controller",
new RouteValueDictionary(myDictionary),
null
) %>
其中myDictionary
应为IDictionary<string, object>
。