How to pass parameters to a controller action method from a jquery callback?
16,297
Solution 1
You can try this, to call a specific controller with action and parameter.
window.location.href = "@Url.Action("Action", "Controller")" +"/"+ parameter ;
Separate your each parameter with a "/".
Solution 2
You can pass the parameters as follows:
window.location.href = '@Url.Action("Action", "Controller", new { param1 = "", param2 = "" })';
Author by
user2721870
Updated on July 25, 2022Comments
-
user2721870 almost 2 years
I am developing a web app using asp.net mvc4. I have an ajax call to a controller action method, and on success callback I need to redirect to a different action method which has 2 parameters. I know window.location.href works for redirecting, but I am not sure how to pass the parameters. Can someone please help?
Thanks