mardi 4 avril 2017

Can't POST an array of string to ASP.NET MVC3

I have an MVC3 controller action:

public ActionResult DoStuff(DoStuffModel model)

The DoStuffModel looks like this:

public class DoStuffModel
{
    public long SomeId { get; set; }
    public List<string> Codes { get; set; }
}

In my jQuery I do this:

 var postData = {
     SomeId: 1,
     Codes: ["code1", "code2", "code3"]
 };

$.post(url, postData, function (data) {});

The URL is correct. The postData looks like this when I log it:

enter image description here

The SomeId gets bound correctly, but Codes remains null. What is going on?

Aucun commentaire:

Enregistrer un commentaire