I have a following method in ASP.NET MVC:
public PartialViewResult SaveUpdateVariants(string TitleEn, string TitleAr, int ItemID, List<ItemVariant> data)
{
}
I am calling it from ajax call like this
$.ajax({
url: '/Inventory/SaveUpdateVariants',
contentType: 'application/json; charset=utf-8', // Include ContentType
data : JSON.stringify(update),
method: "POST",
type: "POST",
success: result => {
gotoOptions();
$("#variant-table tbody").replaceWith(result);
window['variant-table'].refresh();
}
})
Update object is like this
{
"TitleEn": "aa",
"TitleAr": "aa",
"ItemID": "829",
"data": [
{
"ItemVariantID": "-1",
"NameEn": "s",
"NameAr": "a",
"Amount": "10"
}
]
}
But my action method receiving all the parameter as null.
2
Answers
Can you try this
and so on..
since you are using ‘application/json; charset=utf-8’ ContentType you have to add FromBody attribute to action and create in c# the same model as you have in java script