Extended asp.net form field length

Source: Internet
Author: User

Problem: currently, the default asp.net request form field length is 1000. If it exceeds one thousand, an error occurs, or the request. form cannot get the form data after 1000.

Test code:

<% @ Page Language = "C #" %>

<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> No title page </title>
</Head>
<Body>
<Form id = "form1" runat = "server">
<%
Response. Write (Request. Params. AllKeys. Length );
Response. Write ("<br/> ");
For (int I = 0; I <3000; I ++)
{
Response. Write (string. Format ("<input type = 'text' name = 'txt {0} 'value =' {0} '/>", I ));
If (I % 5 = 0)
{
Response. Write ("<br/> ");
}
}
%>
<Input type = "submit" value = "submit"/>
</Form>
</Body>
</Html>

An error occurs when you click Submit. (1. The current status of the object invalidates the operation. 2. The URL encoding form data is invalid ):

Solution:

Add the following configuration in appSettings of Web. config:

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

If you submit the statement again, no error occurs. You can obtain information about all the forms.

Refer:

Http://blogs.msdn.com/ B /paulking/archive/2012/01/16/using-an-http-module-to-assist-in-adjusting-the-value-of-aspnet-maxhttpcollectionkeys-imposed-by-ms11-100.aspx

 

 

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.