Pass js array to mvc controller
Well you have two separate issues. First you have to bind either a application/x-www-form-urlencoded or multipart/form-data or json to your object/array.
Phil Haacked - Model Binding To A List
Excerpt:
start
<form method="post" action="/Home/UpdateInts">
<input type="text" name="ints" value="1" />
<input type="text" name="ints" value="4" />
<input type="text" name="ints" value="2" />
<input type="text" name="ints" value="8" />
<input type="submit" />
</form>
you were to take fiddler and look at what data actually gets posted when clicking the submit button, you’d see the following.
ints=1&ints=4&ints=2&ints=8
The default model binder sees all these name/value pairs with the same name and converts that to a collection with the key ints, which is then matched up with the ints parameter to your action method. Pretty simple!
end
then return another view
Well you have pretty much two options.
First, you use a standard <form>
element with a url and a way to submit the form (submit button, jQuery etc). Pros: its been around litteraly forever and very simple to use. Cons: if there is network outage or something, your user experience is very poor (browser, url cannot be found, so I hit refresh do I resubmit... I don't know.. etc)
Second, you use an Ajax request and send the data. When the response is successful, you window.location
your user to the next screen. Pros: fantastic user experience, if the network fails, you can retry or give the user a way to retry. Cons: definitely more work to implement.