Click here to Skip to main content
13,002,275 members (65,719 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


2 bookmarked
Posted 24 Jan 2012

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

, 24 Jan 2012
Rate this:
Please Sign up or sign in to vote.
Error - Operation is not valid due to the current state of the object.
Whenever a post back is done, this error occurs when form fields are very large in numbers.
The stack trace is:
at System.Web.HttpValueCollection.ThrowIfMaxHttpCollectionKeysExceeded() at System.Web.HttpValueCollection.FillFromEncodedBytes(Byte[] bytes, Encoding encoding) at System.Web.HttpRequest.FillInFormCollection()

By default, the maximum value of MaxHttpCollection is 1000.

To solve this error, increase MaxHttpCollection value. Try adding the following setting in your web.config's <appsettings> block.

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

It can solve your problem. if you have very large records on your page, suppose 600 records in grid and you click on submit, then increase the value of MaxHttpCollection.

Then change value 2000 to 5000 and test again. It will be resolved. :-D


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

You may also be interested in...

Comments and Discussions

GeneralRe: offcourse! Pin
ThatsAlok31-Jan-12 18:56
memberThatsAlok31-Jan-12 18:56 
GeneralReason for my vote of 5 thanks for tip! Pin
beginner201119-Feb-12 15:05
memberbeginner201119-Feb-12 15:05 
GeneralExcellent - than you, solved my problem. You learn something... Pin
mrOneness29-Jan-12 8:43
membermrOneness29-Jan-12 8:43 
GeneralRe: Please vote for this. Pin
Sarvesh Kumar Gupta31-Jan-12 2:00
memberSarvesh Kumar Gupta31-Jan-12 2:00 
Generali Increased the value to 5000 and it was working fine. I had... Pin
mr.akirame28-Jan-12 1:02
membermr.akirame28-Jan-12 1:02 
GeneralThnks Helped me Pin
mr.akirame28-Jan-12 0:57
membermr.akirame28-Jan-12 0:57 
GeneralJust a note, MaxHttpCollection was changed to be 1000 in a U... Pin
sergio_ykz24-Jan-12 12:49
membersergio_ykz24-Jan-12 12:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170624.1 | Last Updated 24 Jan 2012
Article Copyright 2012 by Sarvesh Kumar Gupta
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid