Interface 'System.Web.Mvc.IValueProvider' cannot be indexed because it has no default property

技术标签: 。网  ASP.NET-MVC  vb.net.

This used to work.

<AcceptVerbs(HttpVerbs.Post)> _
Function Widget(ByVal collection As FormCollection) As ActionResult
    ...
    If ... Then
        ModelState.AddModelError(...)
        ModelState.SetModelValue("Gadget", collection.ToValueProvider("Gizmo"))
        Return View()
    End If
    ...
End Function

I upgraded to ASP.NET MVC 2 BetaASP.NET MVC 2 Futures Assembly for Beta 现在 ToValueProvider() fails with this compile-time error:

Interface 'System.Web.Mvc.IValueProvider' cannot be indexed because it has no default property

如何使用 ModelState.SetModelValue() if not with collection.ToValueProvider()?

看答案

Extract taken from the ASP.NET MVC 2 Beta release notes:

Changes in ASP.NET MVC 2 Beta

Introduced the IValueProvider interface, which replaces all usages of IDictionary&lt;string, ValueProviderResult&gt;.

Every property or method argument that accepted IDictionary&lt;string, ValueProviderResult&gt; now accepts IValueProvider. This change affects only applications that include custom value providers or custom model binders.

Examples of properties and methods that are affected by this change include the following:

  • The ValueProvider property of the ControllerBase and ModelBindingContext classes.
  • The TryUpdateModel methods of the Controller class.
  • New CSS classes were added in the Site.css file that are used to style validation messages.

HTHS,
查尔斯


智能推荐

class path resource [mybatis/SqlMapConfig.xml] cannot be opened because it does not exist

在eclipse上配置ssm框架的时候出现一下问题,一直困扰很久。 Error creating bean with name ‘org.mybatis.spring.SqlSessionFactoryBean#0’ defined in file [E:\tools\apache-tomcat-8.5.33\webapps\boot-crm\WEB-INF\classes...

class path resource [applicaiontContext.xml] cannot be opened because it does not exist

这是一个SSM的项目,在创建的初期,配置完三个配置文件之后出现的问题。症状是我的Tomcat死活起不来。打开日志之后看到的这个错。 我看了一下网上的资料都说是配置文件出错,但是我检查了很多遍都没有找出来更坑的是,此刻在配置文件里我按住Command+鼠标左键是可以点击去了,然后自己就很郁闷。 最后抱着试一试的态度在classpath后面加了个* 号就好了。(我项目此刻并没有父工程)然后就好了,心里...

class path resource [SpringMvc.xml] cannot be opened because it does not exist

在做SSM整合的时候,tomcat服务器一启动就报如下的错误, 意思是找不到路径下的文件资源,如下是我的工程框架图 下面是我的Web.xml中的配置 明明已经配置了SpringMvc.xml,却提示没有该文件, 但这些文件不能在任意的地方,必须使用build path 放到指定的位置才可以访问到。 步骤: 选中项目=>(右键)properties=>Java Build Pa...

FileNotFoundException: class applicationContext.xml cannot be opened because it does not exist

maven项目SSM整合时,报application.xml资源找不到或者不存在时去看一下源文件是否有这个src/main/resources目录 解决方案: 右键当前项目,找到属性(properties)后如下图 点击添加后 最后清理并重新运行项目就好了...

class path resource [AA.properties] cannot be opened because it does not exist

刚开始遇到这个问题时,查了一天网上评论,基本说你的文件没放在src目录下,但我的文件确实放在src/main/resources下 无意中在网上看到了解决方案,希望对你有帮助 修改Included为ALL    修改Excluded为None 具体修改方式请自行百度!...

猜你喜欢

Springboot 测试类 [application.yml] cannot be opened because it does not exist

  在 Springboot 中采用 properties 作为配置文件的时候,写测试类会报“[application.yml] cannot be opened because it does not exist ” 错误。改为 yml 就可以了。...

idea class path resource [applicationContext.xml] cannot be opened because it does not exist

idea使用中 class path resource [applicationContext.xml] cannot be opened because it does not exist 解决方法: 将其手动添加到resource,使其识别即可...

无意中发现看书也是一种美

2012年4月25日晚,翻翻自己喜欢的一门语言学习书(python参考手册),无意中发现书中夹着之前的明信片(有一次和同事一起去前门邓丽君音乐生活馆留下来的),感觉学习也是一种美!于是乎拍下这不经意的时刻,哈哈!...

香橙派OrangePi PC Plus开发板连接USB以太网卡测试说明

1) 目前测试过能用的 USB 以太网卡如下所示,其中 RTL8153 USB 千兆网卡插入开 发板的 USB 2.0 Host 接口中测试可以正常使用,但是速率是达不到千兆的,这点请 注意   2) 首先将 USB 网卡插入开发板的 USB 接口中,然后在 USB 网卡中插入网线,确 保网线能正常上网,如果通过 dmesg 命令可以看到下面的 log 信息,说明 USB 网卡...

计算机网络基础:Vlan,网关,dns吗,子网掩码等!面试必备!

很多朋友多次问到什么是网关、dns、子网掩码,三层交换机,它们定位的用途;确实,因为网络技术在弱电中确实应用非常广泛,我们平时在 vip 技术群中也是不断的讨论到网关、vlan、三层交换机或子网掩码等问题,今天我们就一起用通俗方式一次性了解清楚。 一、什么是 vlan? VLAN 中文是 “虚拟局域网”。LAN 可以是由少数几台家用计算机构成的网络,也可以是数以百计的计算机...

问答精选

How to extract beta coefficients for interaction effect in R?

I am examining the interaction between a continuous variable (bloodq) and a categorical variable with three levels (ER, RB, and WB). In order to see how the betas differ across tissue types, I would l...

what is the difference between Flatten() and GlobalAveragePooling2D() in keras

I want to pass the output of ConvLSTM and Conv2D to a Dense Layer in Keras, what is the difference between using global average pooling and flatten Both is working in my case. That both seem to work d...

How to invoke a test step with inputs at runtime from groovy script in SOAP UI?

I am writing a validation groovy script for a test step, intended to test a SOAP Web Service. Now, I want to call the same test step, with different input value from the groovy script. Is it possible?...

Wicket pagestore results wrong page

I have a problem with my web application with wicket. I am using wicket 6.14. I can't say exactly what the problem is, but I can describe the problem. I am using a self written pagestore, which uses h...

Unity load files from outside of resources folder

In unity is it possible to load a resource that is out side of the resources folder. I want the user to be able to set a textAsset variable from a file outside of the Assets directory entirely. You ca...

相关问题

相关文章

热门文章

推荐文章

相关标签

推荐问答