Search Search

#1 worldwide
FREE Coding Lessons

since 1996
   THE BEST WAY to learn ASP & Asp.net!
Advertise Here!
click for details
Credits Host:
DiscountASP.net
Server Admin:
The "Team"
Contact Info.
Charles M. Carroll

my Blog
[prev. Lesson]  Server Variables: Domain/Host Name
     [next Lesson]  Random Content/Rotating Info

Listing All Server Variables by Charles Carroll

The available Server Variables vary based on the result of a combination of the browser software and the server software. They are not always exactly the same on your server and with specific browsers as we document here. There is an easy way to obtain a list. If the script is executed on a  given browser, the Server Variables displayed will reflect that browser plus your server.

   filename=/learn/test/servereach.asp

<Test Script Below>


<%
for each thing in request.servervariables
    tempvalue=request.servervariables(thing)
    response.write thing & "=" & tempvalue & "<br>" 
next
%>

Since the above script appears in dozens of books and websites, we wanted to provide you with a better version. This script may prove useful as it will

  • list all the available server variables
  • skipping the variables ALL_HTTP and ALL-RAW since they are just a "glob" of all the other vars
  • place blank variables at the end
  • display code to retrieve that variable so you can cut and paste into script

   filename=/learn/test/serverall.asp

<Test Script Below>


<html><head>
<TITLE>serverall.asp</TITLE></head>
<body bgcolor="#FFFFFF">
<% 
Response.Write("<P><B>Server Variables</b><br>")
BlankVars="<P><B>Blank Server Variables</b><br>" & vbcrlf
quote=chr(34)
For Each Key in Request.ServerVariables
    If instr(Key,"_ALL")+instr(key,"ALL_")=0 then
        tempvalue=trim(request.servervariables(Key))
        If len(tempvalue)=0 then
            BlankVars=BlankVars & Key & ", "
        Else
            response.write "request.servervariables(" & quote  
            response.write Key & quote & ") "
            response.write " =<br><B>" & tempvalue & "</b><p>" & vbcrlf
        End If
    end if
Next
response.write mid(BlankVars,1,len(BlankVars)-2)
%>
</body></html>

If the server has been secured with https:// then the following script will display some additional variables:
https://secure.activeserverpages.com/learn/test/serverall.asp

There are many worthy charities!!. But perhaps help starving children in Africa or South America AND help Charles too. a $5 tip buys him lunch at McDonalds, a $20 tip buys his kid Hitoshi a new computer game, a $39 tip buys his daughter Michiko a few nice outfits. See our donor list.