我有以下链接
var selectedValue = "someDynamicValue";
var selectedId = 100;
window.location.href = '/Home/' + selectedValue + '/' + selectedId;
如何使用@Url.Action
而不是上面的链接生成?
答案 0 :(得分:0)
我通常这样做:
var selectedValue = "someDynamicValue";
var selectedId = 100;
var href = '@Url.Action("Index", "Home", new { selectedValue = "_selectedValue_", selectedId = "_selectedId_"})';
href = href.replace('_selectedValue_', selectedValue);
href = href.replace('_selectedId_', selectedId);
window.location.href = href;