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

本文探讨了ASP.NET中因UpdatePanel与服务器按钮频繁触发而导致的Operationisnotvalidduetothecurrentstateoftheobject异常。通过调整web.config文件中的aspnet:MaxHttpCollectionKeys设置,可以解决由于单次提交量超过默认限制1000而引发的问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

From http://blog.youkuaiyun.com/zhou_xuexi/article/details/7198131.

PS: 这个问题苦恼了我几天都没有解决,再次非常感谢Zhou_xuexi 同学。

不过我这边产生错误的原因是:

updatepanel 与 服务器端按钮触发频繁所导致的。

1. UI 有个function是当下拉框change时 触发一个 html button (runat=server) onserverclick="btnChange_ServerClick",来加载不同选项的不同信息。

2..包括后台Page_load中在ScriptManager1控件中注册该按钮的回传,也没有解决问题。


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


Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Operation is not valid due to the current state of the object.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[InvalidOperationException: Operation is not valid due to the current state of the object.]
System.Web.HttpValueCollection.ThrowIfMaxHttpCollectionKeysExceeded() +2692302
System.Web.HttpValueCollection.FillFromEncodedBytes(Byte[] bytes, Encoding encoding) +61
System.Web.HttpRequest.FillInFormCollection() +148

[HttpException (0x80004005): The URL-encoded form data is not valid.]
System.Web.HttpRequest.FillInFormCollection() +206
System.Web.HttpRequest.get_Form() +68
System.Web.HttpRequest.get_HasForm() +8735447
System.Web.UI.Page.GetCollectionBasedOnMethod(Boolean dontReturnNull) +97
System.Web.UI.Page.DeterminePostBackMode() +63

System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +133



Operation is not valid due to the current state of the object.这种类型的错误有很多,很多都是针对linq的,但是如果是下面的错误类型System.Web.HttpValueCollection.ThrowIfMaxHttpCollectionKeysExceeded() +2692302

那就是因为

因为上年1229号那次微软发布的最后一次非正常更新程序引起的.在这次安全更新中对于asp.net单次的提交量做了一个最大量限制1000,出现这个异常正是因为页面提交量超过了1000这个限制.这个可以在web.config中更改:
<appSettings>
<add key="aspnet:MaxHttpCollectionKeys" value="5000" />
</appSettings>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值