我有一个复杂的类型,看起来像:
public class ReviewProcessLevelModel {
public int levelType;
public string user;
public string field;
public string[] dtFieldValues;
public string[] dtUsers;
}
我发布的字符串看起来像(在 JSON.stringify 函数之后):
[
{"levelType":0,"user":"71","field":null,"dtFieldValues":null,"dtUsers":null},
{"levelType":1,"user":null,"field":"Dummy","dtFieldValues":null,"dtUsers":null}
]
我的控制器看起来像:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult saveCampaign(IList<ReviewProcessLevelModel> ReviewProcess)
最后,这就是我将数据发送到控制器的方式:
$.ajax({
type: "POST",
url: "@Url.Action("saveCampaign", "SaasAccessCertification")",
traditional: true,
contentType: 'application/json',
dataType: 'json',
data: getRPData() // returns the string above
}).done(function (resp) {
debugger;
}).error(function (resp) {
debugger;
});
该列表带有 2 ReviewProcessLevelModel,但对象始终为空值。
请告知并感谢您的时间。