本文引自VS幫助文件查詢Browser 屬性,
此屬性包含一個HttpBrowserCapabilities 物件。
在HTTP 請求過程中,該物件會從瀏覽器或用戶端裝置中取得訊息,
以便讓您的應用程式知道瀏覽器或用戶端裝置提供的支援類型和等級。
該物件隨後使用強類型屬性和泛型名稱值字典公開有關瀏覽器功能的資訊。
下面的程式碼範例示範如何在頁上的文字方塊中顯示瀏覽器資訊。
=======
Visual Basic
=======
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim s As String = ""
With Request.Browser
s &= "Browser Capabilities" & vbCrLf
s &= "Type = " & .Type & vbCrLf
s &= "Name = " & .Browser & vbCrLf
s &= "Version = " & .Version & vbCrLf
s &= "Major Version = " & .MajorVersion & vbCrLf
s &= "Minor Version = " & .MinorVersion & vbCrLf
s &= "Platform = " & .Platform & vbCrLf
s &= "Is Beta = " & .Beta & vbCrLf
s &= "Is Crawler = " & .Crawler & vbCrLf
s &= "Is AOL = " & .AOL & vbCrLf
s &= "Is Win16 = " & .Win16 & vbCrLf
s &= "Is Win32 = " & .Win32 & vbCrLf
s &= "Supports Frames = " & .Frames & vbCrLf
s &= "Supports Tables = " & .Tables & vbCrLf
s &= "Supports Cookies = " & .Cookies & vbCrLf
s &= "Supports VBScript = " & .VBScript & vbCrLf
s &= "Supports JavaScript = " & _
.EcmaScriptVersion.ToString() & vbCrLf
s &= "Supports Java Applets = " & .JavaApplets & vbCrLf
s &= "Supports ActiveX Controls = " & .ActiveXControls & _
vbCrLf
End With
TextBox1.Text = s
End Sub
=====
C#
=====
private void Button1_Click(object sender, System.EventArgs e)
{
System.Web.HttpBrowserCapabilities browser = Request.Browser;
string s = "Browser Capabilities<br />"
+ "Type = " + browser.Type + "<br />"
+ "Name = " + browser.Browser + "<br />"
+ "Version = " + browser.Version + "<br />"
+ "Major Version = " + browser.MajorVersion + "<br />"
+ "Minor Version = " + browser.MinorVersion + "<br />"
+ "Platform = " + browser.Platform + "<br />"
+ "Is Beta = " + browser.Beta + "<br />"
+ "Is Crawler = " + browser.Crawler + "<br />"
+ "Is AOL = " + browser.AOL + "<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.EcmaScriptVersion.ToString() + "<br />"
+ "Supports Java Applets = " + browser.JavaApplets + "<br />"
+ "Supports ActiveX Controls = " + browser.ActiveXControls
+ "<br />";
Response.Write(s);
}