<% @ Page Language="C#" %>
<% @ Import Namespace="System.Data" %>
<script language="C#" runat="server">
public void Page_Load(object src,EventArgs e)
{
//取得servervariables变量集合
NameValueCollection ServerVariables=Request.ServerVariables;
//产生一个数据表
DataTable dt=new DataTable();
DataRow dr;
dt.Columns.Add(new DataColumn("环境变量",typeof(string)));
dt.Columns.Add(new DataColumn("变量值",typeof(string)));
foreach(string SingleVariable in ServerVariables)
{
dr=dt.NewRow();
dr[0]=SingleVariable;
dr[1]=ServerVariables[SingleVariable].ToString();
dt.Rows.Add(dr);
}
DataGrid1.DataSource=new DataView(dt);
DataGrid1.DataBind();
}
</script>
<html>
<head>
<title>
serverVariables变量值
</title>
</head>
<body>
<asp:DataGrid id="DataGrid1" runat="server"
borderColor="black"
Borderwidth="1"
GridLines="Both"
cellPadding="3"
CellSpacing="0"
Font-Size="8pt"
headerStyle-BackColor="#aaaadd"
AlternatingItemStyle-BackColor="#eeeeee"
/>
</body>
</html>