Tuesday, March 27, 2012

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

Some times when using .NET web applications you have came a cross yellow pages with the stack trace some thing like bellow. 

System.InvalidOperationExceptionOperation is not valid due to the current state of the object.
System.InvalidOperationException: Operation is not valid due to the current state of the object.
at System.Web.HttpRequest.FillInFormCollection()
at System.Web.HttpRequest.get_Form()

Reason for this exception is a recent update which has been done to the .NET framework.  In the Microsoft security update MS11-100, they limit the maximum number of form keys to 1000 in a HTTP request. Because of this update ASP.NET applications rejects the requests which have more than 1000 of form keys. So the error message will be displayed in the browser, with HTTP 500 status code.

This change was made to address mainly the Denial of Service vulnerability. 

This new limit can be override on a per application basic by putting a new "appSettings" in an ASP.NET application’s configuration file. 

No comments:

Post a Comment