HttpBrowserCapabilities使用获取浏览器信息

 

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        HttpBrowserCapabilities hbcMyBrower = new HttpBrowserCapabilities();
        hbcMyBrower = Request.Browser;

        //测试浏览器类型
        Response.Write("浏览器类型是:" + hbcMyBrower.Type);

        Response.Write("<br>");
        Response.Write("浏览器是否是AOL浏览器:" + hbcMyBrower.AOL);

        Response.Write("<br>");
        Response.Write("浏览器是否能语音呼叫:" + hbcMyBrower.CanInitiateVoiceCall);

        Response.Write("<br>");
        Response.Write("浏览器是否支持HTML播放背景音乐:" + hbcMyBrower.BackgroundSounds);

        Response.Write("<br>");
        Response.Write("浏览器是否是测试版:" + hbcMyBrower.Beta);


        Response.Write("<br>");
        Response.Write("浏览器是否支持多个卡片组:" + hbcMyBrower.CanCombineFormsInDeck);
        //测试浏览器是否支持ActiveX
        Response.Write("<br>");
        Response.Write("浏览器是否支持ActiveX控件:" + hbcMyBrower.ActiveXControls);

        Response.Write("<br>");
        Response.Write("支持用http获取XML吗?:" + hbcMyBrower.SupportsXmlHttp);

        Response.Write("<br>");
        Response.Write("浏览器是否支持Cookies:" + hbcMyBrower.Cookies);

        Response.Write("<br>");
        Response.Write("浏览器是否是Web爬行遍历搜索引擎:" + hbcMyBrower.Crawler);

        Response.Write("<br>");
        Response.Write("浏览器一个窗口所允许的提交按钮个数:" + hbcMyBrower.DefaultSubmitButtonLimit);

        Response.Write("<br>");
        Response.Write("浏览器ECMAScript版本号:" + hbcMyBrower.EcmaScriptVersion);

        Response.Write("<br>");
        Response.Write("获取.NET安装版本:" + hbcMyBrower.ClrVersion);

       // Response.Write("<br>");
        //Response.Write("获取.NET所有安装版本:" + hbcMyBrower.GetClrVersions);

        Response.Write("<br>");
        Response.Write("浏览器是否具有专用的上一步按钮:" + hbcMyBrower.HasBackButton);

        Response.Write("<br>");
        Response.Write("浏览器内部标识号:" + hbcMyBrower.Id);

        Response.Write("<br>");
        Response.Write("浏览器支持的输入类型:" + hbcMyBrower.InputType);

        Response.Write("<br>");
        Response.Write("浏览器是否具有颜色显示:" + hbcMyBrower.IsColor);

        Response.Write("<br>");
        Response.Write("浏览器是否支持JAVA:" + hbcMyBrower.JavaApplets);

        Response.Write("<br>");
        Response.Write("浏览器是否支持JAVAScript:" + hbcMyBrower.JavaScript);

        Response.Write("<br>");
        Response.Write("浏览器的整个版本号:" + hbcMyBrower.Version);
    }
}

 

你可能感兴趣的:(browser)