I need to send data to a Controller to Post data currently I'm not using a form only I need to send an array for parameters, what is the right way to do it ?now I'm using this line of code but I know that it is used for Get method instead of Post method:
window.location.href = "@Url.Action("Edit", "PurchaseOrder")?arr" urlParams;
CodePudding user response:
the only easy way to post data to a controller is to do it through a form. but that doesnt mean the form needs any text input or stuff like that as long as code the data in and you make it invisible for a user you can just use a button that looks like a normal button but is actually a form in de code.
else if you dont want to use a form to send the data even if the inputs on the form are not visible you could use AJAX to send a post request but i dont think you want to do that.
if you are already getting the data from a different page in my oppinion it would be easier to just use sessions to store the values when you get them for the first time