无为清净楼资源网 Design By www.qnjia.com

本文实例讲述了asp.net实现获取客户端详细信息代码。分享给大家供大家参考。具体如下:
运行效果截图如下:

asp.net实现获取客户端详细信息

具体代码如下:

其中aspx页面的控件代码:
复制代码 代码如下:<asp:ListBox runat="server" ID="lbHoverTreeInfo" ClientIDMode="Static"> </asp:ListBox>
以下是实现代码:

using System;
using System.Web;
using System.Web.UI;

namespace HoverTreeTool.HvtInfo.KeleyiClient
{
public partial class Index : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string userAgent = Request.UserAgent == null "无" : Request.UserAgent;
if (!IsPostBack)
{lbHoverTreeInfo.Items.Add("您的系统信息为:");
lbHoverTreeInfo.Items.Add("客户端IP[Page.Request.UserHostAddress]:"+ Page.Request.UserHostAddress);
lbHoverTreeInfo.Items.Add("浏览器类型[Request.Browser.Browser]:" + Request.Browser.Browser);
lbHoverTreeInfo.Items.Add("浏览器标识[Request.Browser.Id]:" + Request.Browser.Id);
lbHoverTreeInfo.Items.Add("浏览器版本号[Request.Browser.Version]:" + Request.Browser.Version);
lbHoverTreeInfo.Items.Add("浏览器是不是测试版本[Request.Browser.Beta]:" + Request.Browser.Beta);
lbHoverTreeInfo.Items.Add("浏览器类型[Request.Browser.Type]:" + Request.Browser.Type);
lbHoverTreeInfo.Items.Add("是否支持框架网页[Request.Browser.Frames]:" + Request.Browser.Frames);
lbHoverTreeInfo.Items.Add("是否支持Cookie[Request.Browser.Cookies]:" + Request.Browser.Cookies);
lbHoverTreeInfo.Items.Add("浏览器JScript版本[Request.Browser.JScriptVersion]:" + Request.Browser.JScriptVersion);
lbHoverTreeInfo.Items.Add("屏幕分辨率宽[System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width ]]:" + System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width);
lbHoverTreeInfo.Items.Add("屏幕分辨率高[System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height ]]:" + System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height);
lbHoverTreeInfo.Items.Add("浏览器类型[Request.Browser.Type]:" + Request.Browser.Type);
lbHoverTreeInfo.Items.Add("客户端IP[GetHoverTreeIp()]:" + GetHoverTreeIp());
lbHoverTreeInfo.Items.Add("客户端的操作系统[Request.Browser.Platform]:" + Request.Browser.Platform);
lbHoverTreeInfo.Items.Add("客户端的操作系统[GetHoverTreeOSName(userAgent)]:" + GetHoverTreeOSName(userAgent));
lbHoverTreeInfo.Items.Add("是不是win16系统[Request.Browser.Win16]:" + Request.Browser.Win16);
lbHoverTreeInfo.Items.Add("是不是win32系统[Request.Browser.Win32]:" + Request.Browser.Win32);
lbHoverTreeInfo.Items.Add("客户端.NET Framework版本:Request.Browser.ClrVersion]:" + Request.Browser.ClrVersion);
lbHoverTreeInfo.Items.Add("是否支持Java[Request.Browser.JavaApplets]:" + Request.Browser.JavaApplets);

if (Request.ServerVariables["HTTP_UA_CPU"] == null)
lbHoverTreeInfo.Items.Add("CPU 类型[Request.ServerVariables[\"HTTP_UA_CPU\"]]:未知");
else
lbHoverTreeInfo.Items.Add("CPU 类型[Request.ServerVariables[\"HTTP_UA_CPU\"]]:" + Request.ServerVariables["HTTP_UA_CPU"]);

lbHoverTreeInfo.Items.Add("UserAgent信息[Request.UserAgent]:" + userAgent);
lbHoverTreeInfo.Items.Add("By 何问起工具 http://tool.hovertree.com/info/client/");

}
}

/// <summary>
/// 获取真实IP
/// </summary>
/// <returns></returns>
public string GetHoverTreeIp()
{
string result = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (null == result || result == String.Empty)
{
result = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
}
if (null == result || result == String.Empty)
{
result = HttpContext.Current.Request.UserHostAddress;
}
return result;
}

/// <summary>
/// 根据 User Agent 获取操作系统名称
/// </summary>
private string GetHoverTreeOSName(string userAgent)
{
string m_hvtOsVersion = "未知";
if (userAgent.Contains("NT 6.4"))
{
m_hvtOsVersion = "Windows 10";
}
else
if (userAgent.Contains("NT 6.3"))
{
m_hvtOsVersion = "Windows 8.1";
}
else
if (userAgent.Contains("NT 6.2"))
{
m_hvtOsVersion = "Windows 8";
}
else
if (userAgent.Contains("NT 6.1"))
{
m_hvtOsVersion = "Windows 7";
}else
if (userAgent.Contains("NT 6.0"))
{
m_hvtOsVersion = "Windows Vista/Server 2008";
}
else if (userAgent.Contains("NT 5.2"))
{
m_hvtOsVersion = "Windows Server 2003";
}
else if (userAgent.Contains("NT 5.1"))
{
m_hvtOsVersion = "Windows XP";
}
else if (userAgent.Contains("NT 5"))
{
m_hvtOsVersion = "Windows 2000";
}
else if (userAgent.Contains("NT 4"))
{
m_hvtOsVersion = "Windows NT4";
}
else if (userAgent.Contains("Me"))
{
m_hvtOsVersion = "Windows Me";
}
else if (userAgent.Contains("98"))
{
m_hvtOsVersion = "Windows 98";
}
else if (userAgent.Contains("95"))
{
m_hvtOsVersion = "Windows 95";
}
else if (userAgent.Contains("Mac"))
{
m_hvtOsVersion = "Mac";
}
else if (userAgent.Contains("Unix"))
{
m_hvtOsVersion = "UNIX";
}
else if (userAgent.Contains("Linux"))
{
m_hvtOsVersion = "Linux";
}
else if (userAgent.Contains("SunOS"))
{
m_hvtOsVersion = "SunOS";
}
return m_hvtOsVersion;
}

}
}

以上就是asp.net获取客户端浏览器及主机信息的关键代码,希望对大家的学习有所帮助。

标签:
asp.net获取客户端浏览器信息,asp.net获取客户端主机信息,asp.net获取客户端信息

无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com

RTX 5090要首发 性能要翻倍!三星展示GDDR7显存

三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。

首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。

据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。