开发者

Bind model explicitly

开发者 https://www.devze.com 2023-04-12 10:14 出处:网络
in general,i will use the code below to make binding of Customer model, [HttpPost] public ActionResult Create(Customer model)

in general,i will use the code below to make binding of Customer model,

[HttpPost]
public ActionResult Create(Customer model)
{
  ...
}

now, i want to raise the binding la开发者_如何学JAVAter , not immediately ,like this

[HttpPost]
public ActionResult Create()
{
  //some operations first
  ...
  //binding will start here 
  var model={Bind - To - Customer}
  ...
}

so,how can i achieve that, is it possible ???

Thank much for any suggest


You could use the UpdateModel or TryUpdateModel methods:

[HttpPost]
public ActionResult Create()
{
    //some operations first
    ...
    // binding will start here 
    var model = new Customer();
    UpdateModel(customer);
    ...
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号