1、客户端相关信息
可由Request.ServerVariables获取,下面为基本的使用内容
Request.ServerVariables.Get( "APPL_PHYSICAL_PATH ").ToString(); //获取物理地址
lbscriptName.Text = Request.ServerVariables.Get( "Server_Name ").ToString();//获取服务器类型
lbIp.Text = lbIp2.Text = Request.ServerVariables.Get( "Local_Addr ").ToString();//获取服务器IP
lbPort.Text = Request.ServerVariables.Get( "SERVER_PORT ").ToString();//获取服务器端口
lbProtocol.Text = Request.ServerVariables.Get( "SERVER_PROTOCOL ").ToString();//获取协议
lbServersoftware.Text = Request.ServerVariables.Get( "SERVER_SOFTWARE ").ToString();//获取web服务器
具体查看方法可使用
foreach(string o in Request.ServerVaribles )
{
Response.Write(o + "= " + Request.ServerVaribles[o] + " <br /> ");
}
2、服务器端信息
一部分由Request.ServerVaribles中获取,另外一部分可由Operating及Environment中获取。
OperatingSystem opera = Environment.OSVersion;
lbSystem.Text = opera.Platform.ToString(); //服务器平台
lbSystemOp.Text = opera.VersionString.ToString(); //版本
lbSystemName.Text = Server.MachineName.ToString();//服务器名
lbScript.Text = Server.ScriptTimeout.ToString();//脚本超时时间
string useragent = Request.ServerVariables.Get( "HTTP_USER_AGENT ").ToString();
string[] user = useragent.Split(Convert.ToChar( "; "));
lbscriptName.Text = user[6].ToString();
lbClientSystem.Text = user[2].ToString();
lbXpath.Text = Request.ServerVariables.Get( "PATH_INFO ").ToString();
lbCupnum.Text = Environment.ProcessorCount.ToString(); //服务器CPU数量
}
}