c# 通过UserAgent获取客户端浏览器信息

private void sys_Browser()
        {
            Request.Browser.MajorVersion.ToString();//获取客户端浏览器的主版本号
            Request.Browser.Version.ToString();//获取客户端浏览器的完整版本号
            Request.Browser.Platform.ToString();//获取客户端使用平台的名字
            Request.UserHostAddress.ToString();//获取远程客户端主机IP

            System.Text.StringBuilder strLabel = new System.Text.StringBuilder();
            HttpBrowserCapabilities bc = Request.Browser;

            HttpBrowserCapabilities b = Request.Browser; 
            Label2.Text="登录了系统!浏览器:"+b.Browser + " V" + b.Version;

           // log.Info( Session["ryxm"].ToString() + “登录了系统!浏览器:” + b.Browser + ” V” + b.Version); 
            strLabel.Append("您的浏览器的分辨率为:");
            strLabel.Append(Request.Form["WidthPixel"]);
            strLabel.Append("×");
            strLabel.Append(Request.Form["HeightPixel"]);
            strLabel.Append("");
            strLabel.Append("浏览器基本信息:");
            strLabel.Append("Type = " + bc.Type + "");
            strLabel.Append("Name = " + bc.Browser + "");
            strLabel.Append("Version = " + bc.Version + "");
            strLabel.Append("Major Version = " + bc.MajorVersion + "");
            strLabel.Append("Minor Version = " + bc.MinorVersion + "");
            strLabel.Append("Platform = " + bc.Platform + "");
            strLabel.Append("Is Beta = " + bc.Beta + "");
            strLabel.Append("Is Crawler = " + bc.Crawler + "");
            strLabel.Append("Is AOL = " + bc.AOL + "");
            strLabel.Append("Is Win16 = " + bc.Win16 + "");
            strLabel.Append("Is Win32 = " + bc.Win32 + "");
            strLabel.Append("支持 Frames = " + bc.Frames + "");
            strLabel.Append("支持 Tables = " + bc.Tables + "");
            strLabel.Append("支持 Cookies = " + bc.Cookies + "");
            strLabel.Append("支持 VB Script = " + bc.VBScript + "");
            strLabel.Append("支持 JavaScript = " + bc.JavaScript + "");
            strLabel.Append("支持 Java Applets = " + bc.JavaApplets + "");
            strLabel.Append("支持 ActiveX Controls = " + bc.ActiveXControls + "");
            strLabel.Append("CDF = " + bc.CDF + "");
            strLabel.Append("W3CDomVersion = " + bc.W3CDomVersion.ToString() + "");
           // string browserName = ""; string ver = "";
           // GetBrowserName(Request.UserAgent, out  browserName, out  ver);
           // strLabel.Append("浏览器:" +browserName+ ";"+"版本号:"+ver);
            strLabel.Append("UserAgent = " + Request.UserAgent + "");
            strLabel.Append("");
            strLabel.Append("客户端计算机基本配置:");
            strLabel.Append("UserHostName = " + Request.UserHostName + "");
            strLabel.Append("UserHostAddress = " + Request.UserHostAddress + "");
            strLabel.Append("PDF 6.0 插件是否安装 = " + Request.Form["PDF"] + "");
            Label2.Text = strLabel.ToString();
            



        }

 

你可能感兴趣的:(C#)