记一次mvc获得实体对象为null的问题

在工作中,有次发送ajax请求到后台增加数据,后台拿到的值一直是空的

public JsonResult SaveScore(BASE_SCORE score)
{
ScoreBLL scoreBLL = new ScoreBLL();
return Json(scoreBLL.AddScore(baseScore));
}

 

js

var score = {
SCORETYPEID: typeId,
CLASSID: classId,
PERSONID: personId,
SCORE: itemScore,
REMARK: remark,
SCOREDETAILS: scoreDetails,
};
common.AjaxPost("/BJAppScoring/SaveScore", score, function (data) {
var data = JSON.parse(data);
if (data.status == true) {
alert(data.msg);
window.location.href = "/BJAppScoring/BJAppScoringIndex";
} else {
alert("msg:" + data.msg)
}
}

 

 

找了几个小时,使用排除法一个个属性排除,最后确定问题出现在参数score上,修改了score的类型,发现还是不行,换了个名字,才发现可以,此时才名单,controller接收的参数名和发送的参数中有一个属性score同名,从而导致的错误

posted @ 2019-10-17 01:17  sharestone  阅读(520)  评论(1编辑  收藏  举报