本文介绍了IValueProvider在MVC 2 RC 2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在与MVC 2,似乎在某个时间点,ModelBindingContext.ValueProvider类已被删除并替换IValueProvider。由于这种IM的有麻烦通过ValueProvider.Keys迭代。这里有一个例子和信息,我从code接收完成

I have been working with MVC 2 and it seems that at some point of time the ModelBindingContext.ValueProvider class has been removed and replace with IValueProvider. Because of this im having trouble iterating through the ValueProvider.Keys. Here is an example and the message I receive from Code complete

private void foo(ModelBindingContext myMBC)
{
     var myImportantKeys = myMBC.ValueProvider.Keys.where(keyValue => keyValue.StartsWith("important", StringComparison.InvariantCulture);
     foreach(var importantKey in myImportantKeys)
     {

     }
}

我得到的消息是System.Web.MVC.IValueProvider不包含键的定义。
可能有人见识一下如何解决这个问题。

The message I get is System.Web.MVC.IValueProvider does not contain a definition for Keys. Could someone enlighten me on how to get around this.

推荐答案

天哪,那个code看起来很熟悉!

Gosh, that code looks familiar!

您无法从 IValueProvider 键值的列表。你必须去到源,例如:

You can't get a list of Key values from IValueProvider. You have to go to the source, e.g:

var keys = controllerContext.HttpContext.Request.QueryString.AllKeys.Where(...

这篇关于IValueProvider在MVC 2 RC 2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 19:22