異常詳細信息: 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 編碼窗體數據無效。]
System.Web.HttpRequest.FillInFormCollection() +206
System.Web.HttpRequest.get_Form() +68
System.Web.HttpRequest.get_HasForm() +8743911
System.Web.UI.Page.GetCollectionBasedOnMethod(Boolean dontReturnNull) +97
System.Web.UI.Page.DeterminePostBackMode() +63
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +133
[InvalidOperationException]: 對象的當前狀態使該操作無效。
在 System.Web.HttpValueCollection.ThrowIfMaxHttpCollectionKeysExceeded()
在 System.Web.HttpValueCollection.FillFromEncodedBytes(Byte[] bytes, Encoding encoding)
在 System.Web.HttpRequest.FillInFormCollection()[HttpException]: URL 編碼窗體數據無效。
在 System.Web.HttpRequest.FillInFormCollection()
在 System.Web.HttpRequest.get_Form()
在 System.Web.HttpRequest.get_HasForm()
在 System.Web.UI.Page.GetCollectionBasedOnMethod(Boolean dontReturnNull)
在 System.Web.UI.Page.DeterminePostBackMode()
在 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
[HttpUnhandledException]: 引發類型為“System.Web.HttpUnhandledException”的異常。
在 System.Web.UI.Page.HandleError(Exception e)
在 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
在 System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
在 System.Web.UI.Page.ProcessRequest()
在 System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
在 System.Web.UI.Page.ProcessRequest(HttpContext context)
在 ASP.content_3csalesweb_employeesaleslistseach_aspx.ProcessRequest(HttpContext context)
位置 c:\Users\aa\AppData\Local\Temp\Temporary ASP.NET Files\web\48229cbb\2dbb4478\App_Web_mfh1pmfe.6.cs:行號 0
在 System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
在 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously

 

上述問題的解決方案如下:


ThrowIfMaxHttpCollectionKeysExceeded()
問題在這里.
出現這個異常的原因正是因為上年12月29號那次微軟發布的最后一次非正常更新程序引起的.在這次安全更新中對於asp.net單次的提交量做了一個最大量限制1000,出現這個異常正是因為頁面提交量超過了1000這個限制

解決辦法有兩種:

第一種:用分頁控制頁面數據呈現數據量,盡量把數據放在緩存中,用分頁控制數據呈現量,每頁100條數據。

第二種:這個可以在web.config中更改
<appSettings>
<add key="aspnet:MaxHttpCollectionKeys" value="5000" />
</appSettings>
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM