尝试在一个相当复杂的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中发现的这个漏洞。