一般来说,我将使用下面的代码来绑定Customer模型,
[HttpPost]
public ActionResult Create(Customer model)
{
...
}
现在,我想稍后提高绑定,而不是立即提高绑定,就像这个
[HttpPost]
public ActionResult Create()
{
//some operations first
...
//binding will start here
var model={Bind - To - Customer}
...
}
所以,我怎么能实现这一点,是否可能???
非常感谢任何建议
答案 0 :(得分:6)
您可以使用UpdateModel
或TryUpdateModel
方法:
[HttpPost]
public ActionResult Create()
{
//some operations first
...
// binding will start here
var model = new Customer();
UpdateModel(customer);
...
}