Go to: Articles List

How to get the server variables

Server variables are environment variables that tell you about the environment that your application is running in. True you can find all kinds of information in the server variables, everything from what browser your user is browsing with to what type of server software your host is running.

Browser Detect How To

Here is an example of how to get a server variable:

Response.Write(Request.ServerVariables("ALL_HTTP"))

Place in quotes the name of the server variable you want to see.

Below is a list of the server variables and there descriptions:
Server Variables
ALL_HTTPHTTP Headers from client
ALL_RAWRaw HTTP Headers from client
APPL_MD_PATHMetabase path for the ISAPI DLL
APPL_PHYSICAL_PATHPhysical path to the metabase
AUTH_PASSWORDWhat the user entered in the client's authentication dialog
AUTH_TYPEAuthentication the server used
AUTH_USERAuthenticated user name
CERT_COOKIEUnique ID of the client certificate
CERT_FLAGSIs client certification valid?
CERT_ISSUERIssuer of the client certificate
CERT_KEYSIZENumber of bits in the SSL key
CERT_SECRETKEYSIZENumber of bits in the secret key
CERT_SERIALNUMBERSerial Number for the client certificate
CERT_SERVER_ISSUERIssuer of the the server certificate
CERT_SERVER_SUBJECTSubject of the server certificate
CERT_SUBJECTSubject of the client certificate
CONTENT_LENGTHLength of the content
CONTENT_TYPEMIME type of the current page
GATEWAY_INTERFACECGI version from server
HTTPSIs this secure through SSL?
HTTPS_KEYSIZENumber of bits in the SSL key
HTTPS_SECRETKEYSIZENumber of bits in the secret key
HTTPS_SERVER_ISSUERIssuer of the server certificate
HTTPS_SERVER_SUBJECTSubject of the server certificate
INSTANCE_IDID for this instance in IIS
INSTANCE_META_PATHMetabase path for this instance
LOCAL_ADDRIP of server
LOGON_USERNT login for current user
PATH_INFOServer virtual path
PATH_TRANSLATEDServer absolute path
QUERY_STRINGVariable name value pairs from the url string
REMOTE_ADDRClient IP address for requesting machine
REMOTE_HOSTClient IP address for requesting host
REMOTE_USERRemote User
REQUEST_METHODMethod of request
SCRIPT_NAMEvirtual path and file name of current script
SERVER_NAMEServer name
SERVER_PORTPort being accessed
SERVER_PORT_SECURE0=not secure, 1=secure
SERVER_PROTOCOLName/Version of protocol used
SERVER_SOFTWAREHTTP software used on the server
URLURL without the domain name
HTTP_ACCEPTMIME types the browser knows
HTTP_ACCEPT_LANGUAGEBrowser's language setting
HTTP_CONNECTIONHTTP Connection
HTTP_HOSTDomain hosting this request
HTTP_USER_AGENTBrowser being used
HTTP_PRAGMACache page or not?
HTTP_COOKIECookie related to this page
HTTP_ACCEPT_CHARSETISO character set being accepted

Bolded items are available in IIS 4.0 only. The best way to find out if you can use one of the above items is to print it out and run some tests on it's output.