I’ve got an array of strings in JS. All the members are actually numbers.
My controller has an int[] parameter.
I send it from jquery:
$.ajax({url: someUrl, data: {ids : JSON.stringify(id_array) }, ...)
and I receive it using
public ActionResult MyAction(int[] ids) { ...
The parameter doesn’t get filled, I’ve checked, the Request.Form["ids"] contains “[\"25\",\"26\"]", the string represention of the JSON array.
Is there any way to do this automatically without a lot of int parsing?
Have you tried not stringifying the array and letting mvc’s default model binding do the magic
I’m pretty sure .net MVC will see the array and see it is an array of ints and map it to your array of ints correctly