Hi all,
While working with large data bind on a page and whenever an event "page.postback" is done, an exception "Operation is not valid due to the current state of the object." occurs due to the very large number of form fields. The stack trace is:
at System.Web.HttpValueCollection.ThrowIfMaxHttpCollectionKeysExceeded() at System.Web.HttpValueCollection.FillFromEncodedBytes(Byte[] bytes, Encoding encoding) at System.Web.HttpRequest.FillInFormCollection()
This exception raises because Microsoft Security Update limits number of keys in Forms collection during HTTP POST request.
The default maximum value of MaxHttpCollection is 1000.
To eliminate this exception, increase in numbers of MaxHttpCollection is required. Following changes are mandatory to done in Web.config file:
<appSettings>
<add key="aspnet:MaxHttpCollectionKeys" value="2000" />
</appSettings>
Happy Coding... :)
0 Comment(s)