zoukankan      html  css  js  c++  java
  • 对象的当前状态使该操作无效

    微软在2011年12月29号发布的2011年最后一个更新让哥哥为程序出现的异常头痛了一天. 这个异常在页面数据量小的时候并不会触发,只在页面数据量大的情况下才会出现,开始解决起来让人无从下手,最后才发现猫腻.

    异常信息如下:

    对象的当前状态使该操作无效。 
    说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 

    异常详细信息: System.InvalidOperationException: 对象的当前状态使该操作无效。

    源错误: 

    执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。 
    堆栈跟踪: 


    [InvalidOperationException: 对象的当前状态使该操作无效。]
      System.Web.HttpValueCollection.ThrowIfMaxHttpCollectionKeysExceeded() +2692482
      System.Web.HttpValueCollection.FillFromEncodedBytes(Byte[] bytes, Encoding encoding) +61
      System.Web.HttpRequest.FillInFormCollection() +148

    [HttpException (0x80004005): URL 编码窗体数据无效。] 

    ...

    解决方法如下: 

       Author: dobin   

     Hi i found the solution, it is due to the recent Microsoft security update we are getting this error. Seems they have added a new method called 'ThrowifmaxhttpkeycollectionKeysexceeded' with default value 1000, which means postback can contain only 1000 items.


    Just add the following to your web.config(2.0 and above)

    <appSettings>
    <add key="aspnet:MaxHttpCollectionKeys" value="5000" />
    </appSettings>
    ThrowIfMaxHttpCollectionKeysExceeded()
    问题在这里.
    出现这个异常的原因正是因为上年12月29号那次微软发布的最后一次非正常更新程序引起的.在这次安全更新中对于asp.net单次的提交量做了一个最大量限制1000,出现这个异常正是因为页面提交量超过了1000这个限制.这个可以在web.config中增加参数来更改:
    <appSettings>
    <add key="aspnet:MaxHttpCollectionKeys" value="5000" />
    </appSettings>
  • 相关阅读:
    Delphi Code Editor 之 几个特性(转)
    Delphi Live Bindings 初探
    PC端和移动APP端CSS样式初始化
    移动端H5页面高清多屏适配方案
    js中的事件委托详解
    浏览器页面加载解析渲染机制
    CSS选择器渲染效率
    JS window对象的top、parent、opener含义介绍 以及防止网页被嵌入框架的代码
    关于苹果真机 getFullYear()返回值为NAN的问题
    js事件监听器用法实例详解
  • 原文地址:https://www.cnblogs.com/wzg0319/p/2320805.html
Copyright © 2011-2022 走看看