Error: Operation is not valid due to the current state of Object


Summary

This article provides information regarding error message "Operation is not valid due to the current state of Object" and how to resolve it.

Applies To

This article applies to MachPanel build v5.3.10.

Symptoms

Problem 1:

Exception Details: System.InvalidOperationException: Operation is not valid due to the current state of the object.

System.Web.HttpValueCollection.ThrowIfMaxHttpCollectionKeysExceeded() +4198799



Problem 2:


Sys.WebForms.PageRequestManagerServerErrorException: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500



Solution:

  1. Open Web.Config from Control Panel Website (located at: C:\Program Files\MachSol\MachPanel Control Server), and find <appSettings> key in it.
  2. Write following key under that section: <add key="aspnet:MaxHttpCollectionKeys" value="100000" />

For example:

Code Snippet


<
appSettings>

    <add key="aspnet:MaxHttpCollectionKeys" value="100000" />

</appSettings>

<


Issue History:

The new default max introduced range of ASP.Net HTTP Collection keys by the recent security update is 1000.

Reference URL(s) of Tested Solution:


http://stackoverflow.com/questions/8832470/operation-is-not-valid-due-to-the-current-state-of-the-object-error-during-pos
http://stackoverflow.com/questions/8684049/asp-net-ms11-100-how-can-i-change-the-limit-on-the-maximum-number-of-posted-for