我正在尝试使用 Html.ActionLink 生成 url 并在其末尾使用查询字符串参数

Iam trying to use Html.ActionLink to generate url with queryString parameter at the end of it

我正在尝试使用 Html.ActionLink 生成 URL,在它的末尾带有查询字符串参数,例如:

Controller/Action?id=5

但我得到的是:

Controller/Action/5

使用:

@Html.ActionLink((string)ViewBag.Back, "Action", "Controller", new{id = Model.Id }, new { })

如何将 id 参数作为“?id=”而不是在“/”之后传递 谢谢

更改操作header

public ActionResult Details(int? detailsId)

并调整link

Html.ActionLink((string)ViewBag.Back, "Action", "Controller", new{detailsId = Model.Id }, new { })