url-encoded form data is not valid, operation are not valid due to the current state of the object

Source: Internet
Author: User
Tags form post stack trace

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.