MVC Controller.UpdateModel< T>(T)实际上试图做什么? [英] What does the MVC Controller.UpdateModel<T>(T) actually try to do?

查看:88
本文介绍了MVC Controller.UpdateModel< T>(T)实际上试图做什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

提交MVC页面时,在UpdateModel方法中从System.Web.Mvc控制器对象获取IvalidOperationException.

When I submit my MVC Page I get an IvalidOperationException from System.Web.Mvc Controller object in the UpdateModel method.

MSDN文档指出此方法执行以下操作:

the MSDN documentation states that this method does the following:

使用控制器当前值提供程序中的值更新指定的模型实例.

Updates the specified model instance using values from the controller's current value provider.

值提供者是否在引用当前的Request对象?

Is the value provider referencing the current Request object?

或者它到底从何处获得用于更新模型的值?

Or where exactly does it get the values that it is using to update the model?

UpdateModel方法具体检查什么,当它说那话时,它的含义"是什么?

And what specifically does the UpdateModel method check and what does it 'mean' when it says that

"abcXYZ"类型的模型未成功更新

The model of type 'abcXYZ' was not successfully updated

谢谢

推荐答案

是的,默认值提供程序正在引用当前请求对象(默认情况下为Request.Form.AllKeys.)

Yes, the default value provider is referencing the current request object (by default, Request.Form.AllKeys.)

UpdateModel尝试在模型上设置与该集合中的Key匹配的任何属性.

UpdateModel attempts to set any properties on your Model that match the Key in that collection.

如果由于没有设置器或无法直接转换而无法实现,您将收到该错误.

If it can't because there's either no setter, or no direct cast is possible, you'll receive that error.

这篇关于MVC Controller.UpdateModel< T>(T)实际上试图做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆