Asp.net获取浏览器信息的简单代码

发布时间:2019-08-03编辑:脚本学堂
本文介绍下,Asp.net借助System.Web.HttpBrowserCapabilities类,获取浏览器信息的一例代码,有需要的朋友参考下。

在C#中,获取浏览器信息,大多使用到System.Web.HttpBrowserCapabilities类。

例子,
 

复制代码 代码示例:
//获取浏览器信息
//www.jb200.com
protected void Button1_Click(object sender, EventArgs e)
{
System.Web.HttpBrowserCapabilities browser = Request.Browser;
string s = "Browser Capabilites<br/>"
+ "Type=" + browser.Type + "<br/>"
+ "Name=" + browser.Browser + "<br/>"
+ "Version=" + browser.Version + "<br/>"
+ "Majior Version=" + browser.MajorVersion + "<br/>"
+ "Platform=" + browser.Platform + "<br/>"
+ "Is Beta=" + browser.Beta + "<br/>"
+ "Is AOL=" + browser.AOL + "<br/>"
+ "Is Crawler=" + browser.Crawler + "<br/>"
+ "is Win16=" + browser.Win16 + "<br/>"
+ "is Win32=" + browser.Win32 + "<br/>"
+ "Supports Frames=" + browser.Frames + "<br/>"
+ "Supports Tables=" + browser.Tables + "<br/>"
+ "Supports Cookies=" + browser.Cookies + "<br/>"
+ "Supports VBScript=" + browser.VBScript + "<br/>"
+ "Supports javascript=" + browser.JavaScript + "<br/>"
+ "Supports JavaApplets=" + browser.JavaApplets + "<br/>"
+ "Supports ActiveX Controls=" + browser.ActiveXControls + "<br/>";
Response.Write(s);
}