Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

Trying to debug a random error on a rather complex ASP.net page, there is a good deal of ADO.net MS-SQL which is where I started trouble shooting. However as of yet I haven't been able to narrow it down. Funny thing is when I debug the code locally in VS (against the same DB connection) I don't get an error. Yet when the code is run against IIS it throws the following error. Anyone encountered anything similar ?

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[InvalidOperationException: Operation is not valid due to the current state of the    object.] System.Web.HttpValueCollection.FillFromEncodedBytes(Byte[] bytes, Encoding encoding)  +11368719 System.Web.HttpRequest.FillInFormCollection() +329  [HttpException (0x80004005): The URL-encoded form data is not valid.]    System.Web.HttpRequest.FillInFormCollection() +11482818    System.Web.HttpRequest.get_Form() +157    System.Web.HttpRequest.get_HasForm() +11483620    System.Web.UI.Page.GetCollectionBasedOnMethod(Boolean dontReturnNull) +141    System.Web.UI.Page.DeterminePostBackMode() +100    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean  includeStagesAfterAsyncPoint) +259  Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272 
like image 865
bumble_bee_tuna Avatar asked Jan 23 '12 21:01

bumble_bee_tuna


1 Answers

Could it be in relation to this issue? A suggested workaround is to add the following in your web.config:

<appSettings>     <add key="aspnet:MaxHttpCollectionKeys" value="2000" /> </appSettings> 

Scott Gu also blogged about this vulnerability discovered in ASP.NET.

like image 158
Darin Dimitrov Avatar answered Sep 25 '22 06:09

Darin Dimitrov