我可以使用如下函数中的代码重定向用户:
window.location.href = "@Url.Action("ShippingSummary", "Shipping", new { id = 2 })"
我在变量中有 id,但我需要将它动态分配给 ActionLink。像这样的东西
var ID = 2;
window.location.href = "@Url.Action("ShippingSummary", "Shipping", new { id = ID })"
我收到一个未定义 ID 的错误。我曾尝试先将操作链接创建为字符串,但这没有用。我怎样才能让它工作?