我的控制器中有此代码
public describeAutoScalingGroups() {
const data = (): AWS.AutoScaling.Types.AutoScalingGroupsType => {
return {
// some values here
};
return {
promise: data
};
}
这是模特
public IActionResult Create()
{
return View(new Partner());
}
[HttpPost]
//[ValidateAntiForgeryToken]
public IActionResult Create(Partner model, IFormCollection pForm)
{
_uow.Partner.Insert(model);
return View("List");
}
这是视图
public class Partner
{
public Guid ID;
public string Type;
public string Code;
public string Name;
public string IDCard;
public DateTime BirthDate;
public bool CardStatus;
public string Address;
public string Email;
}
HTTPOST将不会自动绑定模型并始终返回NULL,我检查了FormCollection,它似乎具有所有正确的值,我在做什么错了?
答案 0 :(得分:1)
模型中的属性应定义为自动属性。
public class Partner
{
public Guid ID {get; set;}
public string Type {get; set;}
public string Code {get; set;}
public string Name {get; set;}
public string IDCard {get; set;}
public DateTime BirthDate {get; set;}
public bool CardStatus {get; set;}
public string Address {get; set;}
public string Email {get; set;}
}