asp.net获取服务端和客户端信息
获取服务器名:Page.Server.ManchineName
获取用户信息:Page.User
获取客户端电脑名:Page.Request.UserHostName
获取客户端IP:Page.Request.UserHostAddress
]);
)
clientInfos.Add("计算机/手机", "手机");
else
clientInfos.Add("计算机/手机", "计算机");
clientInfos.Add("Platform", Request.Browser.Platform);
clientInfos.Add("Win16", Request.Browser.Win16 ? "是" : "不是");
clientInfos.Add("Win32", Request.Browser.Win32 ? "是" : "不是");
if(Request.ServerVariables["HTTP_ACCEPT_ENCODING"] == null)
clientInfos.Add("Http Accept Encoding", "无");
else
clientInfos.Add("Http Accept Encoding", Request.ServerVariables["HTTP_ACCEPT_ENCODING"]);
clientInfos.Add("User Agent", userAgent);
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
// 根据 Dictionary 中的内容在 Table 中显示客户端信息
this.Response.Write("<table cellpadding=0 cellspacing=0>");
this.Response.Write("<tr>");
this.Response.Write("<td width=145>项目</td>");
this.Response.Write("<td>值</td>");
this.Response.Write("</tr>");
foreach (string key in clientInfos.Keys)
{
this.Response.Write("<tr>");
this.Response.Write("<td>" + key + "</font></td>");
this.Response.Write("<td>" + clientInfos[key].ToString() + "</td>");
this.Response.Write("</tr>");
}
this.Response.Write("</table>");
}
"))
{
osVersion = "Windows 95";
}
else if (userAgent.Contains("Mac"))
{
osVersion = "Mac";
}
else if (userAgent.Contains("Unix"))
{
osVersion = "UNIX";
}
else if (userAgent.Contains("Linux"))
{
osVersion = "Linux";
}
else if (userAgent.Contains("SunOS"))
{
osVersion = "SunOS";
}
return osVersion;
}