Tip: Detect browser types in asp.net pages

Source: Internet
Author: User
Tags http request tostring win32
Asp.net| Skills | browser

This article is quoted from the VS Help document
Query Browser Properties,
This property contains a HttpBrowserCapabilities object.
During an HTTP request, the object obtains information from the browser or from the client device.
So that your application knows the type and level of support the browser or client device provides.
The object then exposes information about the browser's functionality using strongly typed properties and a generic name-value dictionary.

The following code example demonstrates how to display browser information in a text box on a page.
=======
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);
}



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.