1:
protected void Page_Load(object sender, EventArgs e)
{
this.lblIP.Text = Request.UserHostAddress.ToString();//获取IP
string strSysVersion = "其他";
string strAgentInfo = Request.ServerVariables["HTTP_USER_AGENT"];
if (strAgentInfo.Contains("NT 5.2"))
{
strSysVersion = "Windows 2003";
}
else if (strAgentInfo.Contains("NT 5.1"))
{
strSysVersion = "Windows XP";
}
else if (strAgentInfo.Contains("NT 5"))
{
strSysVersion = "Windows 2000";
}
else if (strAgentInfo.Contains("NT 4.9"))
{
strSysVersion = "Windows ME";
}
else if (strAgentInfo.Contains("NT 4"))
{
strSysVersion = "Windows NT4";
}
else if (strAgentInfo.Contains("NT 98"))
{
strSysVersion = "Windows 98";
}
else if (strAgentInfo.Contains("NT 95"))
{
strSysVersion = "Windows 95";
}
else if (strSysVersion.ToLower().Contains("Mac"))
{
strSysVersion = "Mac";
}
else if (strSysVersion.ToLower().Contains("unix"))
{
strSysVersion = "UNIX";
}
else if (strSysVersion.ToLower().Contains("linux"))
{
strSysVersion = "Linux";
}
else if (strSysVersion.Contains("SunOS"))
{
strSysVersion = "SunOS";
}
this.lblOpSys.Text = strSysVersion;
}
2:
private string getIp()
2 { /*穿过代理服务器取远程用户真实IP地址:*/
3 if(Request.ServerVariables["HTTP_VIA"]!=null)
4 return Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
5 else
6 return Request.ServerVariables["REMOTE_ADDR"].ToString();
7 }
8Label2.Text =getIp();
9HttpBrowserCapabilities bc = new HttpBrowserCapabilities();
10bc = Request.Browser;
11string xitong ="你的操作系统为";
12Label3.Text=xitong+bc.Platform + " 浏览器类型:" + bc.Type;
本文转自94cool博客园博客,原文链接:http://www.cnblogs.com/94cool/archive/2010/01/05/1639900.html,如需转载请自行联系原作者