NameValueCollection = Request.ServerVariables
An Object variable of type NameValueCollection.
The example, as in the previous collection-related examples, writes the contents of the ServerVariables collection to the browser:
Sub Page_Load( ) Dim Counter1, Counter2 As Integer Dim Keys(), subKeys( ) As String Dim SVarsColl As NameValueCollection ' Load ServerVariables into NameValueCollection SVarsColl=Request.ServerVariables ' Get keys into an array Keys = SVarsColl.AllKeys For Counter1 = 0 To Keys.GetUpperBound(0) Message.Text &= "Key: " & Keys(Counter1) & "<br/>" subKeys = SVarsColl.GetValues(Counter1) ' Get all values under this key For Counter2 = 0 To subKeys.GetUpperBound(0) Message.Text &= "Value " & CStr(Counter2) & ": " & _ subKeys(Counter2) & "<br/>" Next Counter2 Message.Text &= "<br/>" Next Counter1 End Sub
In addition to retrieving all the values by looping through the Keys, you can access individual values if you know their key. The following list shows the available keys for the ServerVariable collection:
Returns a string containing all HTTP headers with each header name
taking the form
headername is the name of an HTTP
header in all capital letters.
Provides the same information as ALL_HTTP, but header names are not
all capital letters and are not prefixed with
Returns the path of the application in the IIS metabase.