Operation is not valid due to the current state of the object

本文详细解析了ASP.NET WebForm页面在Postback时遇到字段数限制异常的原因,通过调整web.config配置文件增加表单字段限制值,并分析了Telerik RadGrid组件可能引起的问题,提出了优化方案,旨在解决页面中使用复杂组件导致的异常问题。

在一个 asp.net webform 的程序 postback 时,碰到了这个异常,而且无法调试。

Google 了一下,发现原因原来是 asp.net 对一个 form post 的字段数有限制,在打过最新的安全更新后,这个限制的数目是1000个,超过了就会报这个异常。

解决的办法是在 web.config 里面加一个设置,增大这个限制值:

 <appSettings>

     < add  key ="aspnet:MaxHttpCollectionKeys"  value ="2001"   />
  </ appSettings >

而为什么会有这么多 field 被提交呢,我这个页面用了一个 Telerik 的 RadGrid,其中每一行都有一个 checkbox 进行多选提交,但记录数才100多条,远没到1000.

看来原因可能是 telerik Grid 生成的 html 里面,多生成了很多非必要的表单字段,用来维护一些状态信息之类的,导致表单提交的字段数膨胀了几乎10倍。如果改用轻量级的表格自己实现的话,优化的空间还是很大的。

 

http://stackoverflow.com/questions/8832470/operation-is-not-valid-due-to-the-current-state-of-the-object-error-during-pos 

 

转载于:https://www.cnblogs.com/RChen/archive/2012/04/28/2475568.html

unity APIUpdater encountered some issues and was not able to finish. Unhandled Exception: System.InvalidOperationException: Operation is not valid due to the current state of the object. at Mono.Cecil.ModuleDefinition.ReadSymbols (Mono.Cecil.Cil.ISymbolReader reader) [0x0002f] in <a3989f8c34e6476eaca56644d5639ee8>:0 at Mono.Cecil.ModuleReader.ReadSymbols (Mono.Cecil.ModuleDefinition module, Mono.Cecil.ReaderParameters parameters) [0x0004a] in <a3989f8c34e6476eaca56644d5639ee8>:0 at Mono.Cecil.ModuleReader.CreateModule (Mono.Cecil.PE.Image image, Mono.Cecil.ReaderParameters parameters) [0x00081] in <a3989f8c34e6476eaca56644d5639ee8>:0 at Mono.Cecil.ModuleDefinition.ReadModule (Mono.Disposable`1[T] stream, System.String fileName, Mono.Cecil.ReaderParameters parameters) [0x0000d] in <a3989f8c34e6476eaca56644d5639ee8>:0 at Mono.Cecil.ModuleDefinition.ReadModule (System.String fileName, Mono.Cecil.ReaderParameters parameters) [0x0006c] in <a3989f8c34e6476eaca56644d5639ee8>:0 at Mono.Cecil.AssemblyDefinition.ReadAssembly (System.String fileName, Mono.Cecil.ReaderParameters parameters) [0x00000] in <a3989f8c34e6476eaca56644d5639ee8>:0 at APIUpdater.Framework.Configuration.ObsoleteAttributeBasedConfigurationFactory..ctor (System.String pathToAssemblyWithAttr, System.Boolean reportSourceInformation, System.String[] potentiallyReferencedAssemblyPaths) [0x00079] in <658ad496184746efb4798c63cf56a4bf>:0 at APIUpdater.Framework.Util.IEnumerableExtensions.ComputeConfigurationProvider (System.Collections.Generic.IEnumerable`1[T] assemblyPaths, APIUpdater.Framework.Configuration.ConfigurationProvider provider, System.String[] references) [0x00032] in <658ad496184746efb4798c63cf56a4bf>:0 at ScriptUpdater.Program.ConfigurationProviderFor (APIUpdater.Framework.Configuration.CompilerResponseFile responseFile, System.Text.RegularExpressions.Regex configSourceFilter, APIUpdater.Framework.Log.ConsoleUpdateListener logger) [0x000c8]
最新发布
04-29
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值