Home Resources Forum Advertise Contact

Go Back   Webmaster Forums > Code Talk > ASP Programming

ASP Programming Find help, general discussions about ASP updates, issues and coding techniques here.

Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old 21st December 2006, 09:12 AM
hassen1 hassen1 is offline
WD Addict Poster
 
Join Date: 29th October 2006
Posts: 2,603
Send a message via Yahoo to hassen1
Default 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 Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) browser, and the IP (Internet Protocol) address of your internet connection is 222.165.168.210

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: 222.165.168.210
Find host name of client
<%=Request.ServerVariables("REMOTE_HOST")%>
The result: 222.165.168.210
This will return the hostname or IP address of the server :

find the server domain name
<% =Request.ServerVariables("SERVER_NAME")%>
Server domain name is: www.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: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)

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



Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT -4. The time now is 09:25 PM.


Powered by vBulletin
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC6
vB Ad Management by =RedTyger=