如何更正此问题,以便ActionLink恢复为http://localsite/forum/index/4
(其中4由parent_id定义,如下所示):
@Html.ActionLink("Cancel", "Index", "Forum", new { @class = "btn"}, new{ @id=ViewBag.parent_id })
目前它还原为:
http://localhost:53731/Forum?class=btn
感谢您的帮助,
标记
答案 0 :(得分:3)
只需反转最后两个参数:
@Html.ActionLink("Cancel", "Index", "Forum", new{ @id=ViewBag.parent_id }, new { @class = "btn"})
routeValues应该出现在htmlAttributes之前
请参阅msdn
答案 1 :(得分:2)
看起来你有相反的论点。
@Html.ActionLink("Cancel", "Index", "Forum", new{@id=ViewBag.parent_id }, new { @class = "btn"})