Hello All,
While working with web application, there may be case we got ‘Operation is not valid due to the current state of the object error’ or ‘The URL-encoded form data is not valid’ while doing postback
There may be other reason but one of the reason is form collection reaches its limit of maximum number of keys that it can hold a time. Means you have huge amount of data and you are trying to postback that data to server which end up with this error
‘Operation is not valid due to the current state of the object error’ or ‘The URL-encoded form data is not valid’
Microsoft has added this as security for Form can have 1000 items at a time, however thanks Microsoft also provides way to change this
To change this add following setting into your configuration file
<appSettings>
<add key="aspnet:MaxHttpCollectionKeys" value="10000" />
</appSettings>
In case you have issue with Jason data then you have to add following settings
<appSettings>
<add key="aspnet:MaxJsonDeserializerMembers" value="10000" /></appSettings>
Hope this helps