I am trying to pass JSON data from ajax call to my action method -
Ajax call -
$.ajax({
type: "POST",
url: '/ProjectList/getProjects',
dataType: "json",
contentType: "application/json; charset=utf-8",
data: JSON.stringify(modelData),
success: function (data) {
alert("Testing");
}
});
Model -
EbitModel.cs
public class EbitModel
{
public string ProgramName { get; set; }
public string ProjectName { get; set; }
public string SubprojectName { get; set; }
}
action method of Controller -
ProjectListController.cs
[HttpPost]
public ActionResult getProjects(List<EbitModel> modelData)
{
return null;
}
But I am getting null here in modelData in this action method.
Is there anything am I missing here?
Edit -
JSON data in ModelData as -
[{"ProgramName":"South East","ProjectName":"XYZ","SubprojectName":"LMZ"},{"ProgramName":"South East","ProjectName":"ACB","SubprojectName":"LMZa"}]