Reading QueryStrings in ASP

The QueryString collection is used to retrieve the variable values in the HTTP query string.

The HTTP query string is specified by the values following the question mark (?), like this:

<a href="test.asp?txt=this is a query string test">Link with a query string</a>

The line above generates a variable named txt with the value "this is a query string test".

Query strings are also generated by form submission, or by a user typing a query into the address bar of the browser.


  • variable (Required)
    The name of the variable in the HTTP query string to retrieve.
  • index (Optional)
    Specifies one of multiple values for a variable. From 1 to Request.QuerString(variable).Count.


If you wanted to request data from the QueryString you would do the following:

<% Response.Write( Request.QueryString("txt") ) %>

The above example would return the value from the Querystring named txt and would display it.

This is what would be returned from using the above example:

this is a query string test

Written By: S2H, 9th July 2006