ASP.NET C# 获取浏览器信息

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        HttpBrowserCapabilities bc = Request.Browser;
        Response.Write("<p>浏览器信息:</p>");
        Response.Write("浏览器= " + bc.Browser + "<br>");
        Response.Write("型态= " + bc.Type + "<br>");
        Response.Write("名称= " + bc.Browser + "<br>");
        Response.Write("版本= " + bc.Version + "<br>");
        Response.Write("使用平台= " + bc.Platform + "<br>");
        Response.Write("是否为测试版= " + bc.Beta + "<br>");
        Response.Write("是否为16 位的环境= " + bc.Win16 + "<br>");
        Response.Write("是否为32 位的环境= " + bc.Win32 + "<br>");
        Response.Write("是否支持框架(frame) = " + bc.Frames + "<br>");
        Response.Write("是否支持表格(table) = " + bc.Tables + "<br>");
        Response.Write("是否支持cookie = " + bc.Cookies + "<br>");
        Response.Write("是否支持vb script = " + bc.VBScript + "<br>");
        Response.Write("是否支持java script = " + bc.JavaScript + "<br>");
        Response.Write("是否支持java applets = " + bc.JavaApplets + "<br>");
        Response.Write("是否支持activex controls = " + bc.ActiveXControls + "<br>");
    }
}


效果截图:


HttpBrowserCapabilities还有其他属性,可以自行添加(发现一个很有意思的属性AOL,直接检测浏览器是否是AOL公司的浏览器)


你可能感兴趣的:(ASP.NET C# 获取浏览器信息)