ASP QueryString
Collection
The QueryString
collection is used to retrieve the variable values from the HTTP query string.
The HTTP query string is defined by the values following the question mark (?), such as:
<a href="test.html?txt=this is a query string test">Link with a query string</a>
The above code generates a variable named txt
with the value "this is a query string test".
Query strings can also be generated through form submissions or by users entering queries in the browser's address bar.
Note: If you need to post large amounts of data (more than 100kb), you cannot use Request.QueryString
.
Syntax
Parameter | Description |
---|---|
variable | Required. The variable name in the HTTP query string to retrieve. |
index | Optional. Specifies one of multiple values for a variable. Ranges from 1 to Request.QueryString(variable).Count . |
Examples
Example 1
Iterate through all values of variable n
in the query string:
Assuming this is the request being sent:
And names.asp
contains the following code:
The file names.asp
will display:
Example 2
Assuming this is the string being sent:
The above code generates the following QUERY_STRING
value:
Now, we can use this information in our script:
Output:
If you do not specify any variable values to display, like this:
The output will be: