Codefixer - ASP tutorials, resources and software
New MS SQL 2008 Available – DiscountASP.NET
Home   Articles   Resources   ASP directory   ASP Tutorials   Code Snippets   ASP Applications   Forum
Sunday 7 September
MembersPro PayPal - ASP Membership software

USA & Europe Data Centers – DiscountASP.NET


ASP Partner ASP Partner ASP Partner more partners...

Server Variables

Sometimes you might want to find out more information on your visitors. We can do this using the server variables. These are environment variables that tell us about the environment that your application is running in. Server variables can tell us everything from what browser the visitor is using, to the visitor's ip address, or the last page the visitor came from.

For example I can tell that you are using the CCBot/1.0 (+http://www.commoncrawl.org/bot.html) browser, and the IP (Internet Protocol) address of your internet connection is 38.103.63.60

Server Variables can be called with the following syntax;

<% Request.ServerVariables("Variable Name") %>

Below are a list of some of the more common server variables and how you use them:

This tells us the page the visitor came from
<% = Request.ServerVariables("HTTP_REFERER") %>
The last page you came from:
This is a simple way to display a go back link on a page

get a visitors IP address
<% =Request.ServerVariables("REMOTE_ADDR")%>
Your IP address is: 38.103.63.60

Find host name of client
<%=Request.ServerVariables("REMOTE_HOST")%>
The result: 38.103.63.60

Find the server domain name
<% =Request.ServerVariables("SERVER_NAME")%>
Server domain name is: codefixer.com

This returns the software running on the server
<% Request.ServerVariables("SERVER_SOFTWARE")%>
The Server software is: Microsoft-IIS/6.0

Display the virtual path to the script or application being executed
<% =Request.ServerVariables("SCRIPT_NAME") %>
The result: /tutorials/servervariables.asp

Find out what browsers / Operating System a user has
Display users browser and opertaing system
<% = Request.ServerVariables("HTTP_USER_AGENT") %>
Your browser is: CCBot/1.0 (+http://www.commoncrawl.org/bot.html)

To get a list of all the ServerVariables you can simply copy paste and run this script.


Here's an example of using one of the ServerVariables to create a self referencing form


LinksPro - Directory  and Link  Management Software




ASP.NET 3.5/2.0 Web Hosting: 3 Months FREE – Click Here!




About | Contact | Advertise | Feedback | Hire Us | Link

Site developed by Michael Wall - Web Design Belfast N.Ireland.
Copyright © 2000-2008. All rights reserved.

Do you intend to move to ASP.NET or have you already?
Yes will do
Have done
ASP does fine
Not a priority


Directory Software