.NET框架下向WEB服务器发送请求时的变量集合【代码:遍历方法与变量名/值对】...

1、遍历web服务器变量集合
 
   int loop1, loop2;
   NameValueCollection coll;
   // Load ServerVariable collection into NameValueCollection object.
   coll=Request.ServerVariables;
   // Get names of all keys into a string array.
   String[] arr1 = coll.AllKeys;
   for (loop1 = 0; loop1 < arr1.Length; loop1++)
   {
    Response.Write("Key: " + arr1[loop1] + "<br>");
    String[] arr2=coll.GetValues(arr1[loop1]);
    for (loop2 = 0; loop2 < arr2.Length; loop2++)
    {
     Response.Write("Value " + loop2 + ": " + arr2[loop2] + "<br>");
    }
   }
 
 
2、遍历结果
Key: ALL_HTTP
Value 0: HTTP_CONNECTION:Keep-Alive HTTP_ACCEPT:image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */* HTTP_ACCEPT_ENCODING:gzip, deflate HTTP_ACCEPT_LANGUAGE:zh-cn HTTP_HOST:192.168.0.240 HTTP_USER_AGENT:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322; Alexa Toolbar) HTTP_UA_CPU:x86 HTTP_X_REWRITE_URL:/Test/Test_NameValue.aspx
Key: ALL_RAW
Value 0: Connection: Keep-Alive Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */* Accept-Encoding: gzip, deflate Accept-Language: zh-cn Host: 192.168.0.240 User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322; Alexa Toolbar) UA-CPU: x86 X-Rewrite-URL: /Test/Test_NameValue.aspx
Key: APPL_MD_PATH
Value 0: /LM/W3SVC/545384892/Root
Key: APPL_PHYSICAL_PATH
Value 0: D:\work\woall_last\
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: 545384892
Key: INSTANCE_META_PATH
Value 0: /LM/W3SVC/545384892
Key: LOCAL_ADDR
Value 0: 192.168.0.240
Key: PATH_INFO
Value 0: /Test/Test_NameValue.aspx
Key: PATH_TRANSLATED
Value 0: D:\work\woall_last\Test\Test_NameValue.aspx
Key: QUERY_STRING
Value 0:
Key: REMOTE_ADDR
Value 0: 192.168.0.240
Key: REMOTE_HOST
Value 0: 192.168.0.240
Key: REMOTE_PORT
Value 0: 1265
Key: REQUEST_METHOD
Value 0: GET
Key: SCRIPT_NAME
Value 0: /Test/Test_NameValue.aspx
Key: SERVER_NAME
Value 0: 192.168.0.240
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-IIS/6.0
Key: URL
Value 0: /Test/Test_NameValue.aspx
Key: HTTP_CONNECTION
Value 0: Keep-Alive
Key: HTTP_ACCEPT
Value 0: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*
Key: HTTP_ACCEPT_ENCODING
Value 0: gzip, deflate
Key: HTTP_ACCEPT_LANGUAGE
Value 0: zh-cn
Key: HTTP_HOST
Value 0: 192.168.0.240
Key: HTTP_USER_AGENT
Value 0: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322; Alexa Toolbar)
Key: HTTP_UA_CPU
Value 0: x86
Key: HTTP_X_REWRITE_URL
Value 0: /Test/Test_NameValue.aspx
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值