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
Gravatar # re: Operation is not valid due to the current state of the object.
by Tamoj at 6/12/2012 8:50 PM

Thanks for the post.
Gravatar # re: Operation is not valid due to the current state of the object.
by Sanjay Patil at 6/28/2012 8:51 AM

I set it to 5000, it solves my problem. What is the impact of setting it to more as 10000.
Gravatar # re: Operation is not valid due to the current state of the object.
by renso at 6/30/2012 10:54 AM

The amount you specify has an impact on upload speed of your content, will be proportionally slower. Also the larger it is the more you are open to users uploading files that may be considered inappropriately large in the context of the purpose of the site/page and overloading your storarge capacity.
Gravatar # re: Operation is not valid due to the current state of the object.
by Sanjay Patil at 7/3/2012 6:19 AM

Thank you very much
Gravatar # re: Operation is not valid due to the current state of the object.
by hemant singh at 7/27/2012 10:37 AM

Thanks a lot!!
Gravatar # re: Operation is not valid due to the current state of the object.
by Ankur Negi at 8/9/2012 3:28 AM

Thanks a lot :-)
Gravatar # re: Operation is not valid due to the current state of the object.
by Ly Lele at 9/20/2012 11:04 PM

thx a lot,, I set to 4000 and it's work..

but I still didn't understand why it getting error, when my sheet name use char ' in front and when I erase the char ' I getting this error,,

But after all, thx a lot
Gravatar #  Operation is not valid due to the current state of the object.
by sayli at 10/11/2012 5:08 AM

I am using folowing cod to sent email

MailAddress mailfrom = new MailAddress ( "saylib4@gmail.com" );
MailAddress mailto = new MailAddress ( "txtEmail.Text.ToString()" );
MailMessage newmsg = new MailMessage ( mailfrom, mailto );

newmsg.Subject = "Your PAssword is";
newmsg.Body = "Your PAssword is";

////For File Attachment, more file can also be attached

//Attachment att = new Attachment ( "G:\\code.txt" );
//newmsg.Attachments.Add ( att );

SmtpClient smtps = new SmtpClient ( "smtp.gmail.com", 587 );
smtps.UseDefaultCredentials = false;
smtps.Credentials = new System.Net.NetworkCredential ( "mail@gmail.com", "pwd" );
smtps.EnableSsl = true;
smtps.Send ( newmsg );
Gravatar # re: Operation is not valid due to the current state of the object.
by bhasker at 1/23/2013 12:33 AM

really its work fine.. thanks
Gravatar # re: Operation is not valid due to the current state of the object.
by Matthew at 1/23/2013 7:58 PM

OMG, thank you so much for this awesome quick fix. First google result too!

Thanks.
Gravatar # re: Operation is not valid due to the current state of the object.
by shashi at 5/7/2013 10:05 AM

{System.InvalidOperationException: Operation is not valid due to the current state of the object.
at Oracle.DataAccess.Client.OracleDataReader.GetValue(Int32 i)
at Oracle.DataAccess.Client.OracleDataReader.get_Item(Int32 i)
at Oracle.DataAccess.Client.OracleDataReader.get_Item(String columnName)
Gravatar #  Operation is not valid due to the current state of the object. i have added max size in webconfig but still error occcur
by sandip at 6/1/2013 3:42 AM

plz help me
Thanks u in advanced
Gravatar # re: Operation is not valid due to the current state of the object.
by Nishi at 6/20/2013 1:03 PM

Thanks, saved my time
Gravatar # re: Operation is not valid due to the current state of the object.
by Gokul at 7/2/2013 10:39 AM

Yes after i raised it to 4000,it works , Thanks
Gravatar # re: Operation is not valid due to the current state of the object.
by Mr.Kazoo at 8/14/2013 4:28 PM

Thanks for this post. The error message is so vague and the stack output really not that helpful. Great Post!
Gravatar # re: Operation is not valid due to the current state of the object.
by supriya upadhyay at 9/5/2013 9:38 AM

Thanksss it worked...
Post A Comment
Title:
Name:
Email:
Comment:
Verification:
 
 
Twitter