Computers & ProgrammingASPBackend Development

ASP ServerVariables Collection

The ASP ServerVariables Collection retrieves the values of predetermined environment variables and requests header information.

The ASP ServerVariables collection can provide you with quite a bit of information found in the headers such as IP addresses, server name, virtual path, request method, etc.

It is a common approach to use the ServerVariables collection to obtain your visitors’ IP address, user agent (browser) info, etc. The list of ServerVariables will depend on the server software and on the browser being used.


Request.ServerVariables (SERVER_VARIABLE)


In this example, you can use the Response.Write method in conjunction with a For..Next loop to enumerate the ServerVariables Collection

<!DOCTYPE html>
    <title>Server Variables</title>
    <style type="text/css">
        table {
            margin:20px auto;
            border:1px solid gray;
        tr {
            border:1px solid gray;
        td {
            border:1px solid gray;


For Each x In Request.ServerVariables
    Response.Write("<td>" & x & "</td><td>" & Request.ServerVariables(x) & "</td>")



The following is a listing of the server variables that can be accessed in the ASP ServerVariables Collection.

Server_Variable Description
ALL_HTTP All HTTP headers sent by the client.
ALL_RAW Retrieves all headers in raw form.
APPL_MD_PATH Retrieves the metabase path of the application.
APPL_PHYSICAL_PATH Retrieves the physical path corresponding to the meta base path.
AUTH_PASSWORD Retrieves the value entered in the client’s authentication dialog.
AUTH_TYPE The authentication method that the server uses to validate users.
AUTH_USER Retrieves the raw authenticated user name.
CERT_COOKIE Retrieves the unique ID for client certificate as a string.
CERT_FLAGS bit0 is set to 1 if the client certificate is present and bit1 is set to 1 if the certification authority of the client in invalid.
CERT_ISSUER Retrieves the issuer field of the client certificate.
CERT_KEYSIZE Retrieves the number of bits in Secure Sockets Layer connection key size.
CERT_SECRETKEYSIZE Retrieves the number of bits in server certificate private key.
CERT_SERIALNUMBER Retrieves the serial number field of the client certificate.
CERT_SERVER_ISSUER Retrieves the issuer field of the server certificate.
CERT_SERVER_SUBJECT Retrieves the subject field of the server certificate.
CERT_SUBJECT Retrieves the subject field of the client certificate.
CONTENT_LENGTH Retrieves the length of the content as sent by the client.
CONTENT_TYPE Retrieves the data type of the content.
GATEWAY_INTERFACE Retrieves the revision of the CGI specification used by the server.
HTTP_<HeaderName> Retrieves the value stored in the header HeaderName.
HTTP_ACCEPT Retrieves the value of the Accept header.
HTTP_ACCEPT_LANGUAGE Retrieves a string describing the language to use for displaying content.
HTTP_COOKIE Retrieves the cookie string included with the request.
HTTP_REFERER Retrieves a string containing the URL of the page that referred the request. If redirected, HTTP_REFERER is empty.
HTTP_USER_AGENT Retrieves a string describing the browser that sent the request.
HTTPS Retrieves ON or OFF depending on if the request came in through HTTPS or not.
HTTPS_KEYSIZE Retrieves the number of bits in Secure Sockets Layer connection key size.
HTTPS_SECRETKEYSIZE Retrieves the number of bits in server certificate private key.
HTTPS_SERVER_ISSUER Retrieves the issuer field of the server certificate.
HTTPS_SERVER_SUBJECT Retrieves the subject field of the server certificate.
INSTANCE_ID The ID for the IIS instance in textual format.
INSTANCE_META_PATH The meta base path for the instance of IIS that responds to the request.
LOCAL_ADDR Retrieves the server address on which the request came in.
LOGON_USER Retrieves the Windows account that the user is logged into.
PATH_INFO Retrieves extra path information as given by the client.
PATH_TRANSLATED A translated version of PATH_INFO that takes the path and performs any necessary virtual-to-physical mapping.
QUERY_STRING Retrieves the variables and values stored in the string following the question mark (?) in the HTTP request.
REMOTE_ADDR Retrieves the IP address of the remote host making the request.
REMOTE_HOST Retrieves the name of the host making the request.
REMOTE_USER Retrieves an unmapped user-name string sent in by the user.
REQUEST_METHOD Retrieves the method used to make the request.
SCRIPT_NAME Retrieves a virtual path to the script being executed.
SERVER_NAME Retrieves the server’s host name, DNS alias, or IP address as it would appear in self-referencing URLs.
SERVER_PORT Retrieves the port number to which the request was sent.
SERVER_PORT_SECURE Retrieves a string that contains 0 or 1. If the port is secure, the value will be 1. Otherwise, 0.
SERVER_PROTOCOL Retrieves the name and revision of the request information protocol.
SERVER_SOFTWARE Retrieves the name and version of the server software that answers the request and runs the gateway.
URL Retrieves the base portion of the URL.

In the case where you only need to retrieve one server_variable, you could do so by using the Request.ServerVariables collections.


Leave a Comment

Your email address will not be published.

Scroll to Top