My Mighty Blog

Listen to me and label every single thing I say as a 'fact'. You do it for the news networks, why not me??? These are my views on current events, family, news, government, technology, internet, programming, and whatever else pops into my head.

My Photo
Name:
Location: Central Florida, United States

Good Ol' Boy turned nerd

Previous Posts
Visit the Site

Powered by Blogger

MARVEL and SPIDER-MAN: TM & © 2007 Marvel Characters, Inc. Motion Picture © 2007 Columbia Pictures Industries, Inc. All Rights Reserved. © 2007 Sony Pictures Digital Inc. All rights reserved.
How To: Display All Server Variables (ASP.Net)
Tuesday, June 28, 2005 |
There are many instances where you might want to either write all of the items in the Server Variables collection, or at least be able to step through them. For instance, you may want to know use this information as part of the text returned from a feedback form to let you know what the user's settings and referring URL were. Or, perhaps you want to know this information as part of an error handling schema you have developed.

A simple example of gathering a single piece of information from the Server Variables collection:

Dim strIpNumber As String = Request.ServerVariables("REMOTE_ADDR")
Response.Write(strIpNumber)
' this should return an IP number like 123.123.123.123


Here is an example of how you can loop through and display or collect all of the available Server Variables.

' prepare variables
Dim strText As String = ""
Dim nvcSV As System.Collections.Specialized.NameValueCollection = Request.ServerVariables
Dim arrKeys() As String = nvcSV.AllKeys
Dim iCnt As Integer = 0

' loop through the collection and write the results
For iCnt = 0 To arrKeys.Length - 1
strString &= UCase(arrKeys(iCnt)) & " - " & nvcSV.Get(iCnt).ToString & vbCrLf
Next


You should be able to look at output similar to this:

ALL_RAW - (a summary of all of the most commonly used variables)
APPL_MD_PATH - /LM/W3SVC/3/Root/
APPL_PHYSICAL_PATH - (file system path where the application resides)
AUTH_TYPE -
AUTH_USER -
AUTH_PASSWORD -
LOGON_USER -
REMOTE_USER -
CERT_COOKIE -
CERT_FLAGS -
CERT_ISSUER -
CERT_KEYSIZE -
CERT_SECRETKEYSIZE -
CERT_SERIALNUMBER -
CERT_SERVER_ISSUER -
CERT_SERVER_SUBJECT -
CERT_SUBJECT -
CONTENT_LENGTH - (size of page or document)
CONTENT_TYPE -
GATEWAY_INTERFACE - CGI/1.1
HTTPS - off
HTTPS_KEYSIZE -
HTTPS_SECRETKEYSIZE -
HTTPS_SERVER_ISSUER -
HTTPS_SERVER_SUBJECT -
INSTANCE_ID - 3
INSTANCE_META_PATH - /LM/W3SVC/3
LOCAL_ADDR - (internal IP address)
PATH_INFO - (path of url)
PATH_TRANSLATED - (local file system path of URL)
QUERY_STRING - (querystring collection)
REMOTE_ADDR - (normally the IP number)
REMOTE_HOST - (normally the IP number)
REMOTE_PORT -
REQUEST_METHOD - (normall GET or POST)
SCRIPT_NAME - (web path of url)
SERVER_NAME - (DNS-qualified name of host server)
SERVER_PORT - (HTTP port used)
SERVER_PORT_SECURE - 0
SERVER_PROTOCOL - HTTP/1.1
SERVER_SOFTWARE - (HTTP Server type)
URL - (the url used)
HTTP_CONNECTION - Keep-Alive
HTTP_ACCEPT - (collection of accepted file types)
HTTP_ACCEPT_ENCODING - gzip, deflate
HTTP_ACCEPT_LANGUAGE - en-us
HTTP_COOKIE - (cookie collection)
HTTP_HOST - (DNS-qualified name of host server)
HTTP_REFERER - (previous url)
HTTP_USER_AGENT - (browser used)

Are you interested in seeing an example of ASP.Net using VB.Net? Just let me know...
posted by The Mighty Will @ permalink  

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home