Last post Nov 21, 2018 03:57 PM by bruce (sqlwork.com)
Nov 20, 2018 03:36 AM|Posin_Fang|LINK
I am reading through this documentation:
As the title suggests, I want to know which method is superior for a scalable Web Application. Viewmodel
Nov 21, 2018 06:08 AM|Xing Zou|LINK
Using TryUpdateModel to update fields with posted values is a security best practice because it prevents overposting.
In my opinion, they could exist simultaneously. View Model is used to update the view and PageModel.Model itself is used to receive user input.
To update to the database, you could use PageModel.Model but more secure with TryUpdateModel.
Nov 21, 2018 03:57 PM|bruce (sqlwork.com)|LINK
the default model binding is probably superior (it uses the same code as TryUpdateAsync) for most cases.
TryUpdateAsync() is handy when you want to control when the binding is done, say you need some header values to know which model type to bind to, or you need to pre init the model before binding.
a handy case for TryUpdateAsync() is when you want to first read the model from the database, then bind the post back values to the model. in this case the lookup key would be a url parameter, and the body the postback data.