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


Error Message: Operation is not valid due to the current state of the object. raises when the postkeys exceed the limit provided by microsoft this is being caused by a "critical" patch , which raises mainly as ASP.NET requests that have lots of form keys,limits to limit of 500 on postback items

How to handle Error Message:Operation is not valid due to the current state of the object.



This message as Operation is not valid due to the current state of the object occurs with the scenario when there are more no of postback keys, Which can be explained with the simple example.

Gridview

I have a gridview with 128 rows and 13 columns with and every cell item has a TextBox Template Field.

After entering the details atleast in one of the textbox and immediately after clicking the save Button error will be raised as "Operation is not valid due to the current state of the object."

This is raised as ASP.NET requests that have lots of form keys, files, The Application log on the server has a Warning entry with a Source that is a specific version of ASP.NET, places a limit of 500 on postback items. The new default max introduced by the recent security update is 1000.

Solution for Error Message:Operation is not valid due to the current state of the object.


We have to increase the postback keys limit for that you have to fallow steps
1: start->run->regedit.exe
2. Registry editor will be opened
3. Hkey_LOCAL_MACHINE/SOFTWARE/MICROSOFT/ASP.NET/[VERSNION]->Right Click the version
Select New->DWORD Value->name the DWORD to MaxHttpCollectionKeys.
4. Right click the MaxHttpCollectionKeys->decimal->enter the value as 2000 and save.

register

registerDword


In the Web.config file



Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: