Recently I was working on a ASP.NET project and everything was working right until I pressed a button. Out of nowhere, the famous yellow .NET error page shows up with the following error message: “Operation is not valid due to the current state of the object.”
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Operation is not valid due to the current state of the object.
It totaly surprised me because not long ago everything was working fine. so after doing some research, I found out that Microsoft recently (29-12-2011) released a security update to address several serious security vulnerabilities in the .NET Framework.
But unfortunately this fix breaks pages that contain a lot of POST data. Apparently there seems to be a limit now of 1000 postback items.
To bypass this limitation, you can add a setting key with a custom amount as ‘limitation’ in the configuration file.
<appSettings> <add key="aspnet:MaxHttpCollectionKeys" value="5000" /> </appSettings>