Answer the question
In order to leave comments, you need to log in
ASP.NET How to pass array from javascript to controller?
I am writing an ASP.NET MVC application. The view has a script, it has an array
var array = [];
Question: How to pass this array to the controller method?
Answer the question
In order to leave comments, you need to log in
1) On the client, serialize the passed data to json
2) Create a class in C# similar to the structure of the array element generated by json, for example, SomeClass.
3) Create an action in the controller that receives a sheet of this class as input
public ActionResult MyAction(List<SomeClass> data)
{
....
}
public ActionResult MyAction(string[] data)
{
....
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question