Microsoft Windows Architecture for Developers Training Kit
The Request Object
The Request object provides access to any information that is passed to the Web server by the HTTP request message.
Request Object Collections
The Request object contains five collections that you can use to extract information from an HTTP request.
The following table lists and describes these five collections.
| Collection | Description |
| QueryString | The values of variables in the HTTP query string, specifically the values following the question mark ( ? ) in an HTTP request. |
| Form | The values of form elements posted to the body of the HTTP request message by the form's Post method. |
| Cookies | The values of cookies sent in the HTTP request. |
| ClientCertificate | The values of the certification fields in the HTTP request. |
| ServerVariables | The values of predetermined Web server environment variables. |
Using the Request Object
Each collection of the Request object contains variables that you can use to retrieve information from an HTTP request.
Note
For a complete listing of the predetermined environment variables, see the Active Server Page Roadmap that is installed with ASP.
Example
This example uses the SERVER_NAME variable of the ServerVariables collection to retrieve the name of the Web server:Request.ServerVariables("SERVER_NAME")
You can use the values of these variables to create dynamic HTML to return to the user .
Example
This example uses the name of the Web server to create a hyperlink to a Web page on the same server:<A HREF="http://<%= Request.ServerVariables("SERVER_NAME")%> /MyPage.asp">Link to MyPage</A> You can also access a variable directly without specifying the name of the collection.
Example
This example accesses a server variable directly:Request("SERVER_NAME")
If you access a variable directly, the Web server searches for the variable in a collection in the following order:
- QueryString
- Form
- Cookies
- ClientCertificate
- ServerVariables