如何更正此问题以使 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
谢谢你的帮助,
标记
只需反转最后两个参数:
@Html.ActionLink("Cancel", "Index", "Forum", new{ @id=ViewBag.parent_id }, new { @class = "btn"})
routeValues 应该在 htmlAttributes 之前
见msdn
看起来你的论点颠倒了。
@Html.ActionLink("Cancel", "Index", "Forum", new{@id=ViewBag.parent_id }, new { @class = "btn"})