Solution for “Operation is not valid due to the current state of the object” error

Typically this happens when AJAX controls are involved (Microsoft’s UpdatePanel or others that utilize AJAX POST requests.) The error may be displayed outright or, if nothing is shown on the UI – logged in the Event Viewer. In any case you will get a message similar to:

0x800a139e – Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: Operation is not valid due to the current state of the object

Issue happens because Microsoft Security Update MS11-100 limits number of keys in Forms collection during HTTP POST request. To alleviate this problem you need to increase that number.

This can be done in your application Web.Config in the <appSettings> section (create the section directly under <configuration> if it doesn’t exist). Add 2 lines similar to the lines below to the section:

<add key="aspnet:MaxHttpCollectionKeys" value="2000" /">
<add key="aspnet:MaxJsonDeserializerMembers" value="2000" /">

The above example set the limit to 2000 keys. This will lift the limitation and the error should go away.

8 replies on “Solution for “Operation is not valid due to the current state of the object” error”

  1. Amir says:

    Thanks very much!!! It was a headache trying to figure out the cause of the error!!

  2. vivek says:

    not working at all. Redirecting subreport from main SSRS report.

  3. Yuriy says:

    @vivek: Could you elaborate please?

  4. dhina says:

    really it help for me thank you very much…….

  5. gary says:

    Very helpful, thank you!

  6. Mark says:

    thank you very much, it helped me a lot!

  7. Anshu Mahehwari says:

    thank you very much..really a big headache now has been solved..thanks a lot..

  8. kiran says:

    Thanks . this is much helpful.

Leave a Reply

Your email address will not be published. Required fields are marked *