要看集合里有哪些东西,才知道获取里面的东西。
private
void
Page_Load(
object
sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
// System.Collections.Specialized.NameObjectCollectionBase m = Request.ServerVariables;
int loop1, loop2;
// Load ServerVariable collection into NameValueCollection object.
System.Collections.Specialized.NameValueCollection 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> " );
}
}
}
{
// 在此处放置用户代码以初始化页面
// System.Collections.Specialized.NameObjectCollectionBase m = Request.ServerVariables;
int loop1, loop2;
// Load ServerVariable collection into NameValueCollection object.
System.Collections.Specialized.NameValueCollection 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> " );
}
}
}