微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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中发现的这个漏洞。

原文地址:https://www.jb51.cc/aspnet/253388.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐