Bind model explicitly
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);
...
}
精彩评论