URL pass-Through length limitation workaround

Source: Internet
Author: User

Today write to two page pass value, just start by the URL to add parameters to pass the value,

var strlink = "my.asp?str1=" + str1list + "&str2=" + str2list;
var iheight = 600; Height
var iwidth = 1000; Width
var iTop = (window.screen.availheight-30-iheight)/2; Get the vertical position of the window;
var ileft = (window.screen.availwidth-10-iwidth)/2; Get the horizontal position of the window;
window.open (Strlink, "_blank", "status=yes,resizable=yes,scrollbars=yes,menubar=yes,width=" + IWidth + ", height=" + Iheight + ", left=" + ILeft + ", top=" + iTop)

Where Str1list is a list of the number, STR2 is a list of another ticket, The parameter to my.asp, and then use Request.QueryString to get the value of the parameter to handle, just start my.asp page run no problem, but when the number of data is larger than the time, my.asp page error. After troubleshooting, found that the parameters to my.asp, the number of str1list less, Str2list did not, just know should be the URL value, the data is not cut off.

Then on the Internet to check, found that the URL is a length limit, the internet is said:

Through the problem of URL value, so the URL string is encodeuricomponent the URL string content encoding, problem resolution, but sometimes the request filtering module is configured to deny A request where the query string is too long, the problem is that there is a length limit when passing a string in get mode.

IIS 7 has a length limit for query string. The default is 2048.

The solution to this problem can be modified by Configuration/system.webserver/security/requestfiltering/[email protected] setting.

<requestlimits maxquerystring= "Length"/>

The URL length restrictions for each browser and Web server are as follows:

In the HTTP protocol, there is no limit to the length of the URL, often the maximum length of the URL and the user browser and Web server, different browsers, the maximum acceptable length is often different, of course, not the same Web server can handle the maximum length of the URL is not the same ability.
The following is a description of the maximum processing power of various browsers and servers.

Microsoft Internet Explorer (Browser)
Internet Explorer has a maximum URL limit of 2,083 characters, and if this number is exceeded, the submit button has no response.

Firefox (Browser)
the length of the Firefox browser URL is limited to 65,536 characters, but when I test, the maximum processing time is 8,182 characters, because the length of the URL is limited by the Web server in addition to the browser restrictions.

Safari (Browser)
The maximum URL length is limited to 80,000 characters.

Opera (Browser)
The maximum URL length is limited to 190,000 characters.

Google (Chrome)
Once the URL length exceeds 8,182 characters, the following server error occurs:

Wrote

Request-uri Too Large
The requested URL ' s length exceeds the capacity limit for this server.
apache/2.2.12 (Ubuntu) Server at 127.0.1.1 Port 80

Apache (Server)
Can accept a maximum URL length of 8,192 characters.

Microsoft Internet Information Server (IIS)
The maximum URL that can be accepted is 16,384 characters long.

Through the above data, in order to allow all users to browse normally, our URL should not exceed the maximum length of IE limit (2038 characters), of course, if the URL is not directly provided to the user, but rather to the program calls, the length of the side is only affected by the Web server.

Some friends may take it for granted that if the maximum length is limited to 2038 characters, is it possible to pass about 1000 or so of Chinese characters in a parameter. In fact, this is not true, for the transmission of Chinese, will eventually be urlencode after the encoding of the form of transmission, if the browser encoding is UTF8, a Chinese character after the final encoding of the length of 9 characters.

This is quoted on the Internet, in general, is different browser for the URL has a different length limit.

In this case, I can not really use the URL of the above question to pass the value, because my str1list and str2list length is uncertain, can only think of other ways.

After some pondering, it is found that using the form +post method is recommended to pass the parameter, so there is no size limit.
Actually I'm going to put the current page <form action= "my.asp" method= "POST" >
Then jump to the my.asp page and use Request.Form to get the parameter value.

But my current page cannot do this because the action of the form is already on the other page of the user, so it is not possible to do so.

Finally, by the button submitted by the JS write the submission page, as follows:

var iheight = 600; Height
var iwidth = 1000; Width
var iTop = (window.screen.availheight-30-iheight)/2; Get the vertical position of the window;
var ileft = (window.screen.availwidth-10-iwidth)/2; Get the horizontal position of the window;
window.open ("", "Test", "status=yes,resizable=yes,scrollbars=yes,menubar=yes,width=" + iwidth + ", height=" + IHeight + " , left= "+ ILeft +", top= "+ iTop)

Document.forms[0].action = "my.asp";
Document.forms[0].target = "Test";
Document.forms[0].submit ();

Then, after jumping to the my.asp page, use Request.Form to get the parameter values. Try it, there is no problem when the amount of data is large.

URL pass-Through length limitation workaround

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.