使用英语阅读

通过


HttpRequest.ServerVariables 属性

定义

获取 Web 服务器变量的集合。

public System.Collections.Specialized.NameValueCollection ServerVariables { get; }

属性值

服务器变量的 NameValueCollection

示例

下面的代码示例显示所有命名服务器变量的名称和值。

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 + ": " + Server.HtmlEncode(arr2[loop2]) + "<br>");
   }
}

注解

有关 IIS 支持的服务器变量的列表,请参阅 IIS 服务器变量

适用于