I am able to send a single complex type from ajax to controller however not able to pass a list, always comes up null. *** Code has been updated to show successful passing.
public class EntityAliasTest
{
public int IDTEMP1 { get; set; }
public string NAMETEMP1 { get; set; }
}
[HttpPost]
public IActionResult SaveEntityAliases([FromBody]
List<EntityAliasTest> postData)
{
var es = ModelState.SerializeErrors();
return Json(new[] { postData, es });
}
var aliasList = new Array();
var o = { IDTEMP1 : 0, NAMETEMP1: 'test 0' };
aliasList.push(o);
o = { IDTEMP1 : 1, NAMETEMP1: 'test 1' };
aliasList.push(o);
o = { IDTEMP1 : 2, NAMETEMP1: 'test 2' };
aliasList.push(o);
var postData= JSON.stringify(aliasList);
$.ajax({
url: "DataAdministration/EntityAlias/SaveEntityAliases",
type: "POST",
cache: false,
dataType: "json",
contentType: "application/json; charset=utf-8",
data: postData,
}).done(function (data) {