ASP Server Variables

This simple example will show you some commonly used server variables and a small script that can be used to retrieve the list of server variables and their values.

  • HTTP_REFERER
    Request.ServerVariables(”HTTP_REFERER”)
    Give you the URL of the referring page.
  • HTTP_USER_AGENT
    Request.ServerVariables(”HTTP_USER_AGENT”)
    Returns the information of the browser requesting the page.
  • QUERY_STRING
    Request.ServerVariables(”QUERY_STRING”)
    Returns the Query information from the URL after the question mark (?).
  • REMOTE_ADDR
    Request.ServerVariables(”REMOTE_ADDR”)
    Returns the The IP address of the remote host who has requested the page.

<%

Dim VariableName

Response.Write “<TABLE Border=1 BorderColor=”"BBBBBB”">”
Response.Write “ <TR>”
Response.Write “  <TD><B>Server Variable Name</B></TD>”
Response.Write “  <TD><B>Server Variable Value</B></TD>”
Response.Write “ </TR>”

For Each VariableName In Request.ServerVariables

Response.Write “<TR>”
Response.Write “ <TD>&nbsp;” & VariableName & “</TD>”
Response.Write “ <TD>&nbsp;”
Response.write   Request.ServerVariables(VariableName)
Response.Write “ </TD>”
Response.Write “</TR>”

Next

Response.Write “</TABLE>”

%>


2 Comments

  1. asjidbukhari says:

    Very interesting article. ASP Server Variable script is very helpful for me. Thanks for your sharing

  2. Http Referer says:

    Documents with such an extension provide the existing features derived from ASP; it is also capable of executing script commands within the document. Http Referer

Leave a Reply