Request.ServerVariables["ALL_HTTP"]
%タグ間の.Aspxファイルで使用でき ます。つまり、 <%=Request.ServerVariables["ALL_HTTP"]%>
.csファイルは名前空間を認識しません。何が得られますか?これらの変数をコードファイルの配列に入れる必要があります。
5143 次
1 に答える
2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections.Specialized;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
NameValueCollection coll;
coll = Request.ServerVariables;
// Get names of all keys into a string array.
String[] arr1 = coll.AllKeys;
for (int loop1 = 0; loop1 < arr1.Length; loop1++)
{
Response.Write("Key: " + arr1[loop1] + "<br>");
String[] arr2 = coll.GetValues(arr1[loop1]);
for (int loop2 = 0; loop2 < arr2.Length; loop2++)
{
Response.Write("Value " + loop2 + ": " + Server.HtmlEncode(arr2[loop2]) + "<br>");
}
}
}
}
于 2013-02-09T01:18:18.650 に答える