您好我是ASP Razor的新手,我想知道如何调用URL Action将参数传递给JavaScript控制器中的GET动词。重读相同的页面
javascript {
//some code
@Url.Action("myAction","Conntroller", new { param1 = 123, param2 = 456}) // do not want to open new window but to reload the page
}
public ActionResult myAction(para1, param2)
{
return view()
}
提前致谢
答案 0 :(得分:1)
location.href = "siteurl/controller/action?param1=123¶m2=456";
在你的情况下:
location.href ="@Url.Action("Action", "Controller", new { param1 = 123, param2 = 456})"
答案 1 :(得分:0)
这对我来说很完美
location.href =“@ Url.Action(”Action“,”Controller“)?param1 =”+ value1 +“& param2 =”+ value2;