System.Web.HttpUnhandledException: Throws an exception of type ' System.Web.HttpUnhandledException '. Invalid---> System.Web.HttpException:URL encoded form data. ---> System.InvalidOperationException: The current state of the object invalidates the operation. In System.Web.HttpValueCollection.ThrowIfMaxHttpCollectionKeysExceeded () in System.Web.HttpValueCollection.FillFromEncodedBytes (byte[] bytes, Encoding Encoding) in System.Web.HttpRequest.FillInFormCollection ()---the end of the inner exception stack trace---(Omitted later)
This problem does not occur if the number is small, and this issue occurs when the database is larger.
There are too many form data submitted, you can
1, update to the latest system patches and. NET Patches
2, you can write in the Web. config
<appSettings> <add key= "Aspnet:maxhttpcollectionkeys" value= "/> <add key=" ASPNET: Maxjsondeserializermembers "value="/><!--do not use JSON, this line can not--></appsettings>
Operation is isn't valid due to the current state of the object
When an ASP. WebForm program postback, this exception is encountered and cannot be debugged.
Google a bit, found that the reason is that ASP. NET to a form post field limit, after playing the latest security update, the number of this limit is 1000, more than will be reported this exception.
The workaround is to add a setting to the Web. config to increase this limit:
<appSettings> <add key= "Aspnet:maxhttpcollectionkeys" value= "2001"/> </appSettings>
And why so many field is submitted, I this page with a Telerik RadGrid, each row has a checkbox for multi-select submissions, but the number of records is more than 100, far less than 1000.
It seems likely that the reason for this is that the HTML generated by the Telerik Grid generates many unnecessary form fields to maintain some state information and so on, causing the number of fields submitted by the form to swell almost 10 times times. If you use a lightweight table to implement it yourself, the space for optimization is still very large.
Original address: http://www.jianfangkk.com/aspnet/201511/297
url-encoded form data is not valid, operation are not valid due to the current state of the object