ASP. NET Get client browser and host information

Source: Internet
Author: User
Tags servervariables

Where the control code for the ASPX page:

<asp:listbox runat= "Server" id= "Lbhovertreeinfo" clientidmode= "Static" > </asp:ListBox>

Here is the implementation code:

  1 using System;  2 using System.Web;  3 using System.Web.UI; 4 5 Namespace HoverTreeTool.HvtInfo.KeleyiClient 6 {7 public partial class Index:System.Web.UI.Page 8 {9 protect Ed void Page_Load (object sender, EventArgs e) Ten {one 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 logo [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 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 width [System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width]]:" + System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width); LBHOVERTREEINFO.ITEMS.ADD ("screen resolution high [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 operating system [Request.Browser.Platform]:" + Request.Browser.Platform); LBHOVERTREEINFO.ITEMS.ADD ("Client operating system [Gethovertreeosname (useragent)]:" + gethovertreeosname (useragent)); LBHOVERTREEINFO.ITEMS.ADD ("is not Win16 system [Request.Browser.Win16]:" + Request.Browser.Win16); LbhovertreeinFo. Items.Add ("is not 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 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 PNs 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 Ho-Q-Tool http://tool.hovertree.com/info/client/"); */<summary> 46//For real IP///</summary>//<returns></returns> P Ublic string Gethovertreeip () {A string result = httpcontext.current.request.servervariables["http_x_forwarded_for "]; if (null = = Result | | resUlt = = String.Empty) (= = = httpcontext.current.request.servervariables["REMOTE_ADDR"]; lt | | result = = String.Empty) (+/-) (result = HttpContext.Current.Request.UserHostAddress; //<summary> 64///For operating system name according to User Agent.//</summary> +/-private string Gethovertreeosname (String useragent) "m_hvtosversion =" Unknown "(Useragent.contains (" NT 6.4 ")," m_hvtosversion = "Wi Ndows 10 "; (Useragent.contains ("NT 6.3")) ("$ m_hvtosversion =" Windows 8.1 ";") Ntains ("NT 6.2")) {Bayi m_hvtosversion = "Windows 8"; "The" (")" (Useragent.contains ("NT 6.1")) (M_HVTOSV) ersion = "Windows 7"; }else if (useragent.contains ("NT 6.0")), the m_hvtosversion = "Windows vista/server"; Gent. Contains ("NT 5.2")), {94 m_hvtosversion = "Windows Server 2003"; "(Useragent.contains (" NT 5.1 ")98 m_hvtosversion = "Windows XP",}100 else if (Useragent.contains ("NT 5")) 101 {102 m_hvtosversion = "Windows 2000 "; 103}104 Else if (Useragent.contains (" NT 4 ")) {106 M_hvtosversion =" Windows NT4 "; 107}108 Else if (useragent.contain S ("Me")) 109 {m_hvtosversion = "Windows Me"; 111}112 Else if (Useragent.contains ("98")) 113 {m_hvtosversion = "Windo WS 98 ";}116 else if (Useragent.contains (" "")) 117 {118 m_hvtosversion = "Windows"; 119}120 Else if (useragent.conta INS ("Mac")) 121 {122 m_hvtosversion = "Mac"; 123}124 Else if (useragent.contains ("Unix")), 126 m_hvtosversion = "Unix"; 1 }128 Else if (useragent.contains ("Linux")) 129 {m_hvtosversion = "Linux"; 131}132 Else if (Useragent.contains ("SunOS ")) 133 {134 M_hvtosversion =" SunOS "; 135}136 return m_hvtosversion;137}138 139}140}

Reprinted from: http://hovertree.com/hvtart/bjae/n9f5pp4r.htm

ASP. NET Get client browser and host information

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.