Operation is not valid due to the current state of the object.

Issue:

System.InvalidOperationExceptionOperation is not valid due to the current state of the object.

System.InvalidOperationException: Operation is not valid due to the current state of the object.
   at System.Web.HttpRequest.FillInFormCollection()
   at System.Web.HttpRequest.get_Form()
   at Rhino.Commons.LongConversationManager.LoadConversationFromRequest(Boolean& privateConversation)
   at Rhino.Commons.LongConversationManager.LoadConversation()
   at Rhino.Commons.HttpModules.UnitOfWorkApplication.UnitOfWorkApplication_BeginRequest(Object sender, EventArgs e)
   at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
		
Cause:

Microsoft recently (12-29-2011) released an update to address several serious security vulnerabilities in the .NET Framework. MS11-100 was introduced just recently that handles potential DoS attacks.

Unfortunately the fix has also broken page POSTs with very large amounts of posted data (form fields). MS11-100 places a limit of 500 on postback items. The new default max introduced by the recent security update is 1000.

Adding the setting key to the web-config file overcomes this limitation, as in this example increases it to 2000.

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

Print | posted @ Thursday, January 19, 2012 12:27 PM

Comments on this entry:

Gravatar # re: Operation is not valid due to the current state of the object.
by Mike Steigerwald at 1/20/2012 3:44 PM

Thank you for this post. It solved a problem I had no ideas for.
Gravatar # re: Operation is not valid due to the current state of the object.
by Raship at 1/25/2012 1:17 AM

Yup It works for me! Great
Gravatar # re: Operation is not valid due to the current state of the object.
by Sarit Shamay at 1/26/2012 3:35 AM

I increase this to 4000 only then it was fixed.
Gravatar # re: Operation is not valid due to the current state of the object.
by Monte at 1/26/2012 4:44 AM

Yes, it works, thank you.
Gravatar # re: Operation is not valid due to the current state of the object.
by Monte at 1/26/2012 4:44 AM

Yes, it works, thank you.
Gravatar # re: Operation is not valid due to the current state of the object.
by Jessy at 1/27/2012 10:10 AM

Thank you :-)
Gravatar # re: Operation is not valid due to the current state of the object.
by Jessy at 1/27/2012 10:11 AM

Thank you :-)
Gravatar # re: Operation is not valid due to the current state of the object.
by Rob at 1/27/2012 5:12 PM

Good Deal, saved my bacon
Gravatar # re: Operation is not valid due to the current state of the object.
by Rob at 1/27/2012 5:12 PM

Good Deal, saved my bacon
Gravatar # re: Operation is not valid due to the current state of the object.
by Irf at 1/29/2012 4:59 PM

Wow, thank you so much! This helped solve my issue, one of my aspx pages, where the I had lot of form fields inside a repeater.
Gravatar # re: Operation is not valid due to the current state of the object.
by hrshdk at 1/30/2012 6:28 AM

But It didnt help since my website is in .framework 1.1. kinldy suggest a solution to resolve this.
Gravatar # re: Operation is not valid due to the current state of the object.
by ashwin at 1/30/2012 6:59 AM

thanks a lot ......only when i raised it to 4000
it got fixed..
Gravatar # re: Operation is not valid due to the current state of the object.
by Alok Raj at 2/6/2012 1:51 AM

Thanks a lot...
Gravatar # re: Operation is not valid due to the current state of the object.
by Rajiv at 2/10/2012 5:35 AM

Thanks!!! The suggestion solved my problem.
Gravatar # re: Operation is not valid due to the current state of the object.
by Jess Alfredsen at 2/24/2012 5:14 AM

Thank you !!!!
Gravatar # re: Operation is not valid due to the current state of the object.
by Jess Alfredsen at 2/24/2012 5:15 AM

Thank you !!!
Gravatar # re: Operation is not valid due to the current state of the object.
by Jess Alfredsen at 2/24/2012 5:15 AM

Thank you !!!
Gravatar # re: Operation is not valid due to the current state of the object.
by Greg Gamble at 2/28/2012 1:20 PM

Thanks for the info. I'm using the Telrik MVC Grid and it stores data as json in some instances. When using client side sort handling this would be a big issue for large tables. You think they would have found a better way ...
Gravatar # re: Operation is not valid due to the current state of the object.
by Anushka at 3/7/2012 11:59 PM

Thank you very much. it works fine now.
Gravatar # re: Operation is not valid due to the current state of the object.
by Mark Douglass at 3/14/2012 1:19 AM

Thanks! This worked perfectly. Was struggling to figure out why this would work on certain sets of data on the same page...now I know. Life saver!
Gravatar # re: Operation is not valid due to the current state of the object.
by Manjula Ramanujam at 3/21/2012 1:21 PM

Great, it worked for me. I had no clue about this.
Thank you.
Gravatar # re: Operation is not valid due to the current state of the object.
by Kamalpreet Litt at 3/23/2012 11:43 AM

Thank u very much ............... It solved my problem. Thanks once again
Gravatar # re: Operation is not valid due to the current state of the object.
by will at 4/4/2012 9:25 AM

Where in the web.config file is that supposed to go?
Gravatar # re: Operation is not valid due to the current state of the object.
by Hugo at 4/12/2012 8:23 AM

Thank YOU!!!
Last night I posted an update to my web site and this morning I was greeted by my boss telling be that the web application crashed when changing dates in an ASPxGridView. I had no idea why because the error has nothing to do with what I was working on. The I googled and found this. When added the key with 2000 it worked again. THANK YOU AGAIN for posting the solution to this error!!!
Gravatar # re: Operation is not valid due to the current state of the object.
by Ana at 4/19/2012 6:14 PM

It fixed the problem I was having loading a data
Gravatar # re: Operation is not valid due to the current state of the object.
by Sid at 4/26/2012 4:12 AM

Thanks buddy
Gravatar # re: Operation is not valid due to the current state of the object.
by Shah at 4/30/2012 7:16 AM

thanks mate. save me a good time going up and down trying to find a solution...
Gravatar # re: Operation is not valid due to the current state of the object.
by Eddie at 5/1/2012 2:52 PM

You rule! How seemingly arbitrary and capricious of them. I guess we are not on their email list...
Gravatar # re: Operation is not valid due to the current state of the object.
by Harish Jain at 5/12/2012 6:26 AM

Thanks for this solution,it solves my problem
Gravatar # re: Operation is not valid due to the current state of the object.
by Dinusha at 5/21/2012 1:47 AM

Thank you very much, This post saved my time,
Thanks Again
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 
 
Twitter