asp.net – ASP错误:由于对象的当前状态,操作无效

尝试在一个相当复杂的ASP.net页面上调试一个随机错误,有很多ADO.net MS-sql是我开始麻烦拍摄的地方。但是至今,我还没有把它缩小。有趣的是当我在VS本地调试代码(对同一个DB连接)我没有得到错误。然而,当代码针对IIS运行时,会引发以下错误。有人遇到过类似的东西吗?

错误

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.

堆栈跟踪:

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

[HttpException (0x80004005): The URL-encoded form data is not valid.]
   System.Web.HttpRequest.FillInFormCollection() +11482818
   System.Web.HttpRequest.get_Form() +157
   System.Web.HttpRequest.get_HasForm() +11483620
   System.Web.UI.Page.GetCollectionBasedOnMethod(Boolean dontReturnNull) +141
   System.Web.UI.Page.DeterminePostBackMode() +100
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,Boolean  includeStagesAfterasyncPoint) +259

Version information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272

解决方法

可能与 this issue有关吗?建议的解决方法是在web.config添加以下内容
<appSettings>
    <add key="aspnet:MaxHttpCollectionKeys" value="2000" />
</appSettings>

Scott Gu也在blogged关于ASP.NET中发现的这个漏洞。

相关文章

### 创建一个gRPC服务项目(grpc服务端)和一个 webapi项目(...
一、SiganlR 使用的协议类型 1.websocket即时通讯协议 2.Ser...
.Net 6 WebApi 项目 在Linux系统上 打包成Docker镜像,发布为...
一、 PD简介PowerDesigner 是一个集所有现代建模技术于一身的...
一、存储过程 存储过程就像数据库中运行的方法(函数) 优点:...
一、Ueditor的下载 1、百度编辑器下载地址:http://ueditor....