Exception details: System. InvalidOperationException: the current state of the object invalidates this operation. Real Solution

Source: Internet
Author: User

Source error:

An unhandled exception is generated during the execution of the current Web request. You can use the following exception stack trace information to determine the cause and location of the exception.

Stack trace:

[InvalidOperationException: the current state of the object invalidates this operation.]
System.Web.HttpValueCollection.ThrowIfMaxHttpCollectionKeysExceeded() +2692482
System.Web.HttpValueCollection.FillFromEncodedBytes(Byte[] bytes, Encoding encoding) +61
System. Web. HttpRequest. FillInFormCollection () + 148 [HttpException (0x80004005): the URL-encoded form data is invalid.]
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]: The current state of the object invalidates this operation.
In System. Web. HttpValueCollection. ThrowIfMaxHttpCollectionKeysExceeded ()
In System. Web. HttpValueCollection. FillFromEncodedBytes (Byte [] bytes, Encoding encoding)
In System. Web. HttpRequest. FillInFormCollection () [HttpException]: The URL encoding form data is invalid.
In System. Web. HttpRequest. FillInFormCollection ()
In System. Web. HttpRequest. get_Form ()
In System. Web. HttpRequest. get_HasForm ()
In System. Web. UI. Page. GetCollectionBasedOnMethod (Boolean dontReturnNull)
In System. Web. UI. Page. DeterminePostBackMode ()
In System. Web. UI. Page. ProcessRequestMain (Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
[HttpUnhandledException]: raises an exception of the type "System. Web. HttpUnhandledException.
In System. Web. UI. Page. HandleError (Exception e)
In System. Web. UI. Page. ProcessRequestMain (Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
In System. Web. UI. Page. ProcessRequest (Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
In System. Web. UI. Page. ProcessRequest ()
In System. Web. UI. Page. ProcessRequestWithNoAssert (HttpContext context)
In System. Web. UI. Page. ProcessRequest (HttpContext context)
In ASP. content_3csalesweb_employeesaleslistseach_aspx.ProcessRequest (HttpContext context)
Location c: \ Users \ aa \ AppData \ Local \ Temp \ Temporary ASP. NET Files \ web \ 48229cbb \ 2dbb4478 \ App_Web_mfh1pmfe.6.cs: Row 0
In System. Web. HttpApplication. CallHandlerExecutionStep. System. Web. HttpApplication. IExecutionStep. Execute ()
In System. Web. HttpApplication. ExecuteStep (IExecutionStep step, Boolean & completedSynchronously

 

The solution to the above problems is as follows:


ThrowIfMaxHttpCollectionKeysExceeded ()
Here is the problem.
This exception was caused by the last abnormal update program released by Microsoft in December 29 of the previous year. in this security update, the maximum number of asp.net submissions is 1000. This exception occurs because the Page Submission volume exceeds the limit of 1000.

There are two solutions:

First, use pagination to control the amount of data displayed on the page, store the data in the cache as much as possible, and use pagination to control the amount of data displayed. Each page contains 100 data records.

Type 2: this can be changed in web. config
<Deleetask>
<Add key = "aspnet: MaxHttpCollectionKeys" value = "5000"/>
</AppSettings>
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.