1 // The following example shows the names and values of all named server variables.
2 Int Loop1, loop2;
3 Namevaluecollection Coll;
4
5 // Load servervariable collection into namevaluecollection object.
6 Coll = Request. servervariables;
7 // Get names of all keys into a string array.
8 String [] arr1 = Coll. allkeys;
9 For (Loop1 = 0 ; Loop1 < Arr1.length; loop1 ++ )
10 {
11 Response. Write ( " Key: " + Arr1 [loop1] + " <Br> " );
12 String [] arr2 = Coll. getvalues (arr1 [loop1]);
13 For (Loop2 = 0 ; Loop2 < Arr2.length; loop2 ++ )
14 {
15 Response. Write ( " Value " + Loop2 + " : " + Arr2 [loop2] + " <Br> " );
16 }
17 }
The result is as follows:
Key: all_http
Value 0: http_connection: keep-alive http_accept: */* http_accept_encoding: gzip, deflate http_accept_language: ZH-CN http_cookie: Asp. net_sessionid = udfdmq454mn2fa45q1aox255 http_host: localhost http_user_agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; sv1 ;. net CLR 1.1.4322) http_ua_cpu: x86
Key: all_raw
Value 0: Connection: keep-alive accept: */* accept-encoding: gzip, deflate accept-language: ZH-cn cookie: Asp. net_sessionid = udfdmq454mn2fa45q1aox255 HOST: localhost User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; sv1 ;. net CLR 1.1.4322) UA-CPU: x86
Key: appl_md_path
Value 0:/lm/w3svc/1/root/ZOA/zzbpublicgoods
Key: appl_physical_path
Value 0: D: \ project \ ZOA \ zzbpublicgoods \
Key: auth_type
Value 0:
Key: auth_user
Value 0:
Key: auth_password
Value 0:
Key: logon_user
Value 0:
Key: remote_user
Value 0:
Key: cert_cookie
Value 0:
Key: cert_flags
Value 0:
Key: cert_issuer
Value 0:
Key: cert_keysize
Value 0:
Key: cert_secretkeysize
Value 0:
Key: cert_serialnumber
Value 0:
Key: cert_server_issuer
Value 0:
Key: cert_server_subject
Value 0:
Key: cert_subject
Value 0:
Key: content_length
Value 0: 0
Key: content_type
Value 0:
Key: gateway_interface
Value 0: CGI/1.1.
Key: https
Value 0: Off
Key: https_keysize
Value 0:
Key: https_secretkeysize
Value 0:
Key: https_server_issuer
Value 0:
Key: https_server_subject
Value 0:
Key: instance_id
Value 0: 1
Key: instance_meta_path
Value 0:/lm/w3svc/1
Key: local_addr
Value 0: 127.0.0.1
Key: path_info
Value 0:/ZOA/zzbpublicgoods/webform1.aspx
Key: path_translated
Value 0: D: \ project \ ZOA \ zzbpublicgoods \ webform1.aspx
Key: QUERY_STRING
Value 0:
Key: remote_addr
Value 0: 127.0.0.1
Key: remote_host
Value 0: 127.0.0.1
Key: remote_port
Value 0: 1158
Key: request_method
Value 0: Get
Key: script_name
Value 0:/ZOA/zzbpublicgoods/webform1.aspx
Key: SERVER_NAME
Value 0: localhost
Key: server_port
Value 0: 80
Key: server_port_secure
Value 0: 0
Key: server_protocol
Value 0: HTTP/1.1
Key: server_software
Value 0: Microsoft-Microsoft IIS/6.0
Key: URL
Value 0:/ZOA/zzbpublicgoods/webform1.aspx
Key: http_connection
Value 0: keep-alive
Key: http_accept
Value 0 :*/*
Key: http_accept_encoding
Value 0: gzip, deflate
Key: http_accept_language
Value 0: ZH-CN
Key: http_cookie
Value 0: Asp. net_sessionid = udfdmq454mn2fa45q1aox255
Key: http_host
Value 0: localhost
Key: http_user_agent
Value 0: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; sv1;. Net CLR 1.1.4322)
Key: http_ua_cpu
Value 0: x86