Showing the browser type and its capabilities in ASP.NET C#

Different types of features are being supported by different browsers or by the different versions of the same browser.

When we make a request for a page to the server through the browser then Asp.net automatically determines the browser capabilites. and render the appropriate markup for that particular browser.However,sometimes some control features are not being supported by older browsers.

Browser capability means whether a particular browser support different features like java script, Frames, Cookies, etc.

Sometimes we need to check the browser capabilities in our application.

So, we can do this with the help of HttpBroserCapabilities object. We can write the code on click of the button or wherever we feel its necessity. For the time being I have put the code on the Page_Load event of my Default.aspx.cs page.

protected void Page_Load(object sender, EventArgs e)
    {
        System.Web.HttpBrowserCapabilities browser = Request.Browser;
        string s = "Browser Capabilities\n"
            + "Type = " + browser.Type + "\n"
            + "Name = " + browser.Browser + "\n"
            + "Version = " + browser.Version + "\n"
            + "Major Version = " + browser.MajorVersion + "\n"
            + "Minor Version = " + browser.MinorVersion + "\n"
            + "Platform = " + browser.Platform + "\n"
            + "Is Beta = " + browser.Beta + "\n"
            + "Is Crawler = " + browser.Crawler + "\n"
            + "Is AOL = " + browser.AOL + "\n"
            + "Is Win16 = " + browser.Win16 + "\n"
            + "Is Win32 = " + browser.Win32 + "\n"
            + "Supports Frames = " + browser.Frames + "\n"
            + "Supports Tables = " + browser.Tables + "\n"
            + "Supports Cookies = " + browser.Cookies + "\n"
            + "Supports VBScript = " + browser.VBScript + "\n
            + "Supports JavaScript = " +
                browser.EcmaScriptVersion.ToString() + "\n"
            + "Supports Java Applets = " + browser.JavaApplets + "\n"
            + "Supports ActiveX Controls = " + browser.ActiveXControls;

        Response.Write(s);

    }

I have requested this page through my mozilla browser then we see the result:
 

Browser Capabilities Type = Firefox13.0.1 Name = Firefox Version = 13.0.1 Major Version = 13 Minor Version = 0 Platform = WinNT Is Beta = False Is Crawler = False Is AOL = False Is Win16 = False Is Win32 = True Supports Frames = True Supports Tables = True Supports Cookies = True Supports VBScript = False Supports JavaScript = 1.4 Supports Java Applets = True Supports ActiveX Controls = False

Ebook Download
View all
Learn
View all