开发者

What does Controller.TryUpdateModel() do in detail? Why might it fail

开发者 https://www.devze.com 2022-12-30 07:01 出处:网络
I tried to use Controller.TryUpdateModel() of ASP.NET MVC. What does it do in detail. In my example it fails (i开发者_C百科.e. returns false). So how can I find out, what is the reason for the failure

I tried to use Controller.TryUpdateModel() of ASP.NET MVC. What does it do in detail. In my example it fails (i开发者_C百科.e. returns false). So how can I find out, what is the reason for the failure?


This method will use a model binder associated to the model to create and bind its properties from the request values. The method might fail for example if you have an integer property in your model and you try to bind it to some string value which cannot be parsed to an integer. You might look at the ModelState dictionary to see if the model is valid and if there are some errors associated.

0

精彩评论

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