possible duplicate Passing a list of objects to an MVC controller method using jQuery Ajax
but my question is when i miss
var things = [ {employee:'test',effectiveDate:'',expirationDate:'' }, { employee:'test',effectiveDate:'',expirationDate:'' } ]; $.ajax({ contentType: 'application/json', type: "POST", url: "/MyController/CheckMethod", dataType: "json", data: JSON.stringify(things), async: false, success: function (data) {
for the controller method, which is [HTTPPOPST] JsonResult, then I get valuein myList<MYMODEL>
[HTTPPOPST] JsonResult
value
List<MYMODEL>
but when I take the controller method as 'ActionResult', then I get nullinList<MYMODEL>
'ActionResult'
null
why is there something wrong?
, JSON . , JSON.stringfy.
data: {"things" : things},
public IActionResult ActionName(List<Model> things)
ajax. ,
public ActionResult CheckMethod(List<MYMODEL> items)
data: JSON.stringify('items': things),
data: JSON.stringify(things),
, JsonResult - ActionResult (. ).
JsonResult
ActionResult
JSON, JsonResult; , Visual Studio , . ActionResult, .
JSON
, ; , List<MYMODEL>, "" , . , , AJAX, , ActionResult ( JsonResult).
AJAX