0

how can we redirect from one view to another using window.location.href with parameters?

code in javascript

window.location.href = "your/url?10&12";

and my method

public ActionResult url(int val1, int val2)
{

}

both val1 and val2 is 0

what can we do here to get the value?

Hary
  • 5,690
  • 7
  • 42
  • 79

1 Answers1

0

Use url helpers when generating urls to a controller action.

window.location.href = '@Url.Action("Url", "Home")' + '?val1=' +x+'&val2='+y;

and add [HttpGet] decorator on Action

[HttpGet]
public ActionResult url(int val1, int val2)
{

}
Kiank
  • 16
  • 2