ASP Request Object

Discover the ASP Request object, which exposes everything the browser sent — posted form fields, URL parameters, and server or client environment details.

What Is the Request Object?

The Request object represents the incoming HTTP request from the visitor's browser. It is the mirror image of Response: where Response sends things out, Request lets you read everything that came in, organized into a handful of collections you access by name.

Request.Form

Example: Reading a posted field

<%
Dim comment
comment = Request.Form("comment")

If comment <> "" Then
    Response.Write("You said: " & comment)
End If
%>

Request.QueryString

Example: Reading a URL parameter

<%
Dim category
category = Request.QueryString("category")

Response.Write("Browsing category: " & category)
%>

<!-- Visiting page.asp?category=shoes prints: Browsing category: shoes -->

Request.ServerVariables

Beyond form fields and URL parameters, Request.ServerVariables gives you access to details about the server and the client that sent the request — things like the visitor's IP address, their browser string, and which HTTP method was used, none of which come from a form at all.

Example: Reading environment details

<%
Response.Write("Your IP address: " & Request.ServerVariables("REMOTE_ADDR") & "<br>")
Response.Write("Your browser: " & Request.ServerVariables("HTTP_USER_AGENT") & "<br>")
Response.Write("This site is running on: " & Request.ServerVariables("SERVER_NAME"))
%>
Server VariableDescription
REMOTE_ADDRIP address of the visitor making the request
HTTP_USER_AGENTBrowser and operating system string sent by the client
SERVER_NAMEHost name of the server handling the request
REQUEST_METHOD"GET" or "POST", depending on how the page was requested
HTTP_REFERERURL of the page the visitor came from, if any
Note: Checking Request.ServerVariables("REQUEST_METHOD") lets a single ASP page tell whether it was reached with GET or POST, which is handy when the same page both displays a form and processes its submission.
Note: Values like HTTP_USER_AGENT and HTTP_REFERER are supplied by the client and can be changed to anything by the visitor. Never rely on them for security checks such as authentication — use them for logging, analytics, or display purposes only.

Exercise: ASP Response and Request

What does Response.Write do on an ASP page?