jquery - Form with Select Multiple Post to WebAPI -
i using c# web api receive post of form have select multiple.
my model in web api method like:
{model: { username: "test", groups: [ {id:123}, {id: 2}]}}
in other words, model class fields, , array of complex type.
webapi works correctly if form data posted is:
username:test groups[0][id]:123 groups[1][id]:2
however, if serialize form $(this).serialize()
like:
username:test groups[][id]:123 groups[][id]:2
which webapi doesn't handle correctly.
this defining select as:
<select name="groups[][id]" >...</select>
i have tried other ways define select, can't accomplish it.
i able workaround building object based on form's elements , passing object ajax instead of $(this).serialize
, ugly hack.
does webapi somehow supports receiving properties arrays in model posted form?
thanks.
i had same problem , resolved using https://www.nuget.org/packages/imranb.modelbindingfix
Comments
Post a Comment