If you have ever noticed a long URL with a question mark (?) in the middle while you are at a Web site, you have probably seen an example of a query string. Query strings contain user data appended to a URL.
Unlike data in browser cookies, the data in a query string can't be stored between user visits to a Web site, but they are useful for retaining user information during a single visit.
Using GETs and POSTs
The METHOD field of an HTML FORM command allows the use of either POST or GET for its method, and requests the URL in the ACTION field (in our case, an ASP script) from the server. Each method is useful, but used differently.
POST is used for passing more complicated information or information to be processed
(in a situation, for example, where a user clicking the browser's Reload button could result in an accidental duplicate order).
In the previous lesson, we used Request.Form to read data submitted with the POST method.
GET is typically used to pass parameters for retrieving data, and can be used to pass hidden fields as well, such as a user's current location in a Web application.
Using the GET method encodes the Form data and appends it to the end of the ACTION URL.
A ? separator follows the URL; other form fields are separated from each other by a &. character.
How ASP interprets a query string
The official specification for URL syntax breaks down URLs as follows:
As in the MouseOver example, you can specify an index to refer to a specific element within a multiple-value query variable, or you can reference the total number of array elements in a variable. For the example in the MouseOver,
Request.QueryString("item"). Count would be 2.
The next lesson describes how the Request object can read a browser cookie.