绑定到FubuMVC中的空IEnumerable会导致绑定错误

时间:2013-11-15 17:06:52

标签: model-binding fubumvc

我的模型中有一个IEnumerable<string>值的属性,它从复选框数组中获取值。如果没有选中复选框,Fubu会以绑定错误响应。

Fubu会寻找各种潜在的价值来源。当它最终检查Cookies时,它会引发异常:

System.NotSupportedException
   в FubuMVC.Core.Http.Cookies.CookieValueSource.GetChildren(String key) в c:\BuildAgent\work\ae412c8ad89b884b\src\FubuMVC.Core\Http\Cookies\CookieValueSource.cs:строка 46
   в FubuCore.Binding.RequestData.GetEnumerableRequests(String prefixOrChild) в c:\BuildAgent\work\4dafc5966c0aefb4\src\FubuCore\Binding\RequestData.cs:строка 84
   в FubuCore.Binding.BindingContext.GetEnumerableRequests(String name) в c:\BuildAgent\work\4dafc5966c0aefb4\src\FubuCore\Binding\BindingContext.cs:строка 66
   в FubuCore.Binding.CollectionPropertyBinder.EnumerableBuilder`1.FillValues(PropertyInfo property, IBindingContext context) в c:\BuildAgent\work\4dafc5966c0aefb4\src\FubuCore\Binding\CollectionPropertyBinder.cs:строка 64
   в FubuCore.Binding.CollectionPropertyBinder.Bind(PropertyInfo property, IBindingContext context) в c:\BuildAgent\work\4dafc5966c0aefb4\src\FubuCore\Binding\CollectionPropertyBinder.cs:строка 35
   в FubuCore.Binding.StandardModelBinder.<>c__DisplayClassc.b__b(IPropertyContext propertyContext) в c:\BuildAgent\work\4dafc5966c0aefb4\src\FubuCore\Binding\StandardModelBinder.cs:строка 68
   в FubuCore.Binding.BindingContext.ForProperty(PropertyInfo property, Action`1 action) в c:\BuildAgent\work\4dafc5966c0aefb4\src\FubuCore\Binding\BindingContext.cs:строка 106

绑定代码将此异常解释为绑定失败,并返回以下continuation(“Packages”是属性的名称):

{"success":false,"refresh":false,"errors":[{"category":null,"field":"Packages","label":"en-US_Packages","message":"Data is formatted incorrectly"}]}

除了添加假隐藏字段外,我该如何正确地做到这一点?我正在使用最新的公共NuGets:FubuCore 1.1.0和FubuMVC.Core 1.1.0。

1 个答案:

答案 0 :(得分:0)

最近修好了这个