Posts
33
Comments
186
Trackbacks
0
ThrowIfMaxHttpCollectionKeysExceeded error message when doing postback

Microsoft recently (12-29-2011) released an update to address several serious security vulnerabilities in the .NET Framework. One of the fixes introduced by MS11-100 temporarily mitigates a potential DoS attack involving hash table collisions. It appears this fix breaks pages that contain a lot of POST data. In our case, on pages that have very large checkbox lists. Why would this be the case?

There are some information on this limit to be at 1000....so if your webpage was working fine earlier and it all of a sudden started crashing with the following message -

"Operation is not valid due to the current state of the object." whenever a post back is done.

the stack trace is

at System.Web.HttpValueCollection.ThrowIfMaxHttpCollectionKeysExceeded() at System.Web.HttpValueCollection.FillFromEncodedBytes(Byte[] bytes, Encoding encoding) at System.Web.HttpRequest.FillInFormCollection()

Then  probably you have crossed the default limit for the postdata collection key.

To overcome this limit, add the following line of code in you <appsetting> section of web.config

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

Hope this helps someone..           

posted on Monday, March 5, 2012 4:05 PM Print
Comments
Gravatar
# re: ThrowIfMaxHttpCollectionKeysExceeded error message when doing postback
Quicksilver
10/25/2012 3:49 PM
thanks very much. it helped
Gravatar
# re: ThrowIfMaxHttpCollectionKeysExceeded error message when doing postback
Ivan
11/9/2012 1:52 PM
Thanks. You save a lot of time!
Gravatar
# re: ThrowIfMaxHttpCollectionKeysExceeded error message when doing postback
Denis Cook
1/28/2013 10:01 PM
Hi Vipin

Thanks for the fix mate

Are you aware of any adverse effects of a config change from a security aspect?

ta

Gravatar
# re: ThrowIfMaxHttpCollectionKeysExceeded error message when doing postback
Anson Aricatt
4/26/2013 10:30 AM
Thanks. You done it
Gravatar
# re: ThrowIfMaxHttpCollectionKeysExceeded error message when doing postback
Siddhartha Sengupta
6/15/2013 10:13 AM
THNX A LOT ITS DONE!!!!!!
Gravatar
# re: ThrowIfMaxHttpCollectionKeysExceeded error message when doing postback
Khanh
11/14/2013 9:49 AM
Thanks, Great
Gravatar
# re: ThrowIfMaxHttpCollectionKeysExceeded error message when doing postback
Paco
4/7/2014 1:17 PM
It helped me. Thanks a lot
Gravatar
# re: ThrowIfMaxHttpCollectionKeysExceeded error message when doing postback
Stefan
4/22/2014 4:21 AM
Thanks, this worked for me.
Gravatar
# re: ThrowIfMaxHttpCollectionKeysExceeded error message when doing postback
zahid
6/12/2014 5:40 AM
Million Thanks
Gravatar
# re: ThrowIfMaxHttpCollectionKeysExceeded error message when doing postback
Geoff Simmons
7/5/2014 12:21 PM
worked immediately. Good to know the reason. Thanks a lot.
Gravatar
# re: ThrowIfMaxHttpCollectionKeysExceeded error message when doing postback
bajaj
7/21/2014 12:39 PM
thanks a lot u save us from boss
Gravatar
# re: ThrowIfMaxHttpCollectionKeysExceeded error message when doing postback
harold
8/4/2014 8:49 PM
thanks, it helped a ton!
Gravatar
# re: ThrowIfMaxHttpCollectionKeysExceeded error message when doing postback
Ankit
8/7/2014 8:41 AM
<appSettings>
<add aspnet:MaxHttpCollectionKeys" value="2001" />
</appSettings>

is it working in .Net Framework 3.5 ?
Gravatar
# re: ThrowIfMaxHttpCollectionKeysExceeded error message when doing postback
Beginner
12/6/2014 7:54 AM
thanks a lot.
Gravatar
# re: ThrowIfMaxHttpCollectionKeysExceeded error message when doing postback
Ajay
1/8/2015 7:43 AM
Superb. Thanks a lot. It was breaking my head.
Gravatar
# re: ThrowIfMaxHttpCollectionKeysExceeded error message when doing postback
Bikash
3/23/2015 5:56 AM
Is value 2001 the only value, or we can increase this value to meet our requirement?
Gravatar
# re: ThrowIfMaxHttpCollectionKeysExceeded error message when doing postback
Marcmars
8/19/2015 3:07 PM
Thank you so much for this... my webpart couldn't save or edit because of this... what is the default value?
Gravatar
# re: ThrowIfMaxHttpCollectionKeysExceeded error message when doing postback
Rubens
12/18/2015 5:39 PM
You guys can increase that value as you with; "2001" is an example and the default value is "1000".

Thank you
Gravatar
# re: ThrowIfMaxHttpCollectionKeysExceeded error message when doing postback
ranjith
12/29/2016 7:32 AM
not working for me

Post Comment

Title *
Name *
Email
Comment *  
Verification