The example of this article describes the ASP.net implementation to obtain the client detail code. Share to everyone for your reference. Specifically as follows:
The screenshot of the running effect is as follows:
The specific code is as follows:
The control code for the ASPX page:
Copy Code code as follows:
<asp:listbox runat= "Server" id= "Lbhovertreeinfo" clientidmode= "Static" > </asp:ListBox>
Here is the implementation code:
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?
"None": request.useragent; if (! IsPostBack) {LBHOVERTREEINFO.ITEMS.ADD ("Your System Information is:"); LbHoverTreeInfo.Items.Add ("Client ip[
Page.Request.UserHostAddress]: "+ Page.Request.UserHostAddress);
LBHOVERTREEINFO.ITEMS.ADD ("browser type [Request.Browser.Browser]:" + Request.Browser.Browser);
LBHOVERTREEINFO.ITEMS.ADD ("browser identification [REQUEST.BROWSER.ID]:" + Request.Browser.Id);
LBHOVERTREEINFO.ITEMS.ADD ("browser version number [Request.Browser.Version]:" + Request.Browser.Version);
LBHOVERTREEINFO.ITEMS.ADD ("Browser is not beta version [Request.Browser.Beta]:" + Request.Browser.Beta);
LBHOVERTREEINFO.ITEMS.ADD ("browser type [Request.Browser.Type]:" + Request.Browser.Type);
LBHOVERTREEINFO.ITEMS.ADD ("Support frames page [Request.Browser.Frames]:" + Request.Browser.Frames); LBHOVERTREEINFO.ITEMS.ADD ("Whether to support Cookie[request.browser.")Cookies]: "+ Request.Browser.Cookies";
LBHOVERTREEINFO.ITEMS.ADD ("Browser JScript version [Request.Browser.JScriptVersion]:" + Request.Browser.JScriptVersion); LBHOVERTREEINFO.ITEMS.ADD ("screen resolution is wide [System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width]]:" +
System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width); LBHOVERTREEINFO.ITEMS.ADD ("High screen resolution [System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height]]:" +
System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height);
LBHOVERTREEINFO.ITEMS.ADD ("browser type [Request.Browser.Type]:" + Request.Browser.Type);
LBHOVERTREEINFO.ITEMS.ADD ("Client Ip[gethovertreeip ()]:" + GETHOVERTREEIP ());
LBHOVERTREEINFO.ITEMS.ADD ("Client's operating system [Request.Browser.Platform]:" + Request.Browser.Platform);
LBHOVERTREEINFO.ITEMS.ADD ("Client's operating system [Gethovertreeosname (useragent)]:" + gethovertreeosname (useragent));
LBHOVERTREEINFO.ITEMS.ADD ("is not the Win16 system [Request.Browser.Win16]:" + Request.Browser.Win16);
LBHOVERTREEINFO.ITEMS.ADD ("is not the Win32 system [REQUEST.BROWSER.WIN32]:" + Request.Browser.Win32); LbhovertreeinfO.items.add ("client. NET Framework version: Request.Browser.ClrVersion]:" + Request.Browser.ClrVersion);
LBHOVERTREEINFO.ITEMS.ADD ("Whether to support Java[request.browser.javaapplets]:" + Request.Browser.JavaApplets); if (request.servervariables["http_ua_cpu"] = = null) lbHoverTreeInfo.Items.Add ("CPU type [request.servervariables[\"
Http_ua_cpu\ "]]: Unknown"); else LbHoverTreeInfo.Items.Add ("CPU type [request.servervariables[\" Http_ua_cpu\ "]]:" + request.servervariables["HTTP
_ua_cpu "]);
LBHOVERTREEINFO.ITEMS.ADD ("useragent information [request.useragent]:" + useragent);
LBHOVERTREEINFO.ITEMS.ADD ("By what ask Tool http://tool.hovertree.com/info/client/"); }///<summary>///get real IP///</summary>///<returns></returns> public string Gethovertreeip ( {string result = Httpcontext.current.request.servervariables[' http_x_forwarded_for ']; if (null = result | | Tring. Empty) {result = Httpcontext.current.request.servervariables[' remote_addr ']; if (null = result | | = = = String.emp ty) {result = HttpcOntext.
Current.Request.UserHostAddress;
return result;
///<summary>///Obtain the operating system name///</summary> private String Gethovertreeosname (String useragent) based on the User Agent {String m_hvtosversion = "Unknown"; if (Useragent.contains ("NT 6.4")) {m_hvtosversion = "Windows x";} else if (useragent.c Ontains ("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";} else if (Useragent.contains ("NT 4")) {M_hvtos
Version = "Windows NT4"; else if (Useragent.contains ("Me")) {m_hvtosversion = "Windows Me";} else if (Useragent.contains ("98")) {
M_hvtosversion = "Windows 98"; else if (useragent.contains) {m_hvtosversion = "Windows)"} else if (Useragent.contains ("Mac") {M_hvtosversi
on = "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;
}
}
}
Above is asp.net to obtain the client browser and host information of the key code, I hope to help you learn.