Selasa, 24 Juli 2012

Note for my self: 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 block. 
 
<appSettings>
    <add key="aspnet:MaxHttpCollectionKeys" value="2001" />
 </appSettings>
 
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






Note 2:


It doesn't sound like this update is actually affecting you, it may be another update that was recently released.  View the HTML code that is produced, and that when you submit the form generates this error - then count the number of and elements that are in between the (or each, if there are more than one)
...
tags.  If there are a lot of these (over 500 or 1000) then this is probably your problem, but I suspect (also, due to what you are saying the nature of the form is) that this form will only have 8-10 of such elements - if this is the case then this update probably isn't causing your problem.

Tidak ada komentar:

Posting Komentar

#PesanBuatAwan #3

"Om, saya ingin menikahi anak om. Saya tau om tidak setuju, tapi saya berjanji akan membahagiakan anak om."  -berkata tanpa bertan...