Operation is not valid due to the current state of the object

Posted: 15th March 2012 in .NET, Exceptions, SharePoint
Tags:

Okay, I’ve not done any blogging for a while, been mega busy… But I just came across this problem in a MOSS environment, which after a bit of digging was easily resolved. Just thought I’d share…

While trying to filter a list with a Telerik component. I came across the above error ( also shown in the screen shot below)

image

After looking in the log files I discovered that is was throwing an exception of type ThrowIfMaxHttpCollectionKeysExceeded

Entry in the log file 

Error=Operation is not valid due to the current state of the object.   at System.Web.HttpValueCollection.ThrowIfMaxHttpCollectionKeysExceeded()     at System.Web.HttpValueCollection.FillFromEncodedBytes(Byte[] bytes, Encoding encoding)     at System.Web.HttpRequest.FillInFormCollection()

After a bit of digging it turns out that this is a direct result of an MS update to thwart DOS attacks. As can be seen by the entry on Scott Guthrie’s Blog.  However, in this case, i was trying to fix an internal application so DOS attacks were not an issue.

To fix this issue add the following to the web.config file

<appSettings>
  <add key="aspnet:MaxHttpCollectionKeys" value="Number greater than 1000 until the error goes away" />
</appSettings>

I needed to set this value to 3000 to resolve the issue.   Surprised smile

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s