Search code examples
javascriptasp.net-mvc-3razor-2

Call GET from JavaScript and passing parameters


Hi I am new to ASP Razor and i want to know how to call URL Action to pass parameter to GET verb in the controller from JavaScript.Reloading the same page

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()
}

Thanks in advance


Solution

  • location.href = "siteurl/controller/action?param1=123&param2=456";
    

    in your case:

    location.href ="@Url.Action("Action", "Controller", new { param1 = 123, param2 = 456})"