Getting browser capability in asp .net

Example of asp .net applciaion to get browser capabilites infromation
When a client send a request of a page then server also receive client browser information for checking wheather client able to see requested page or not etc...


<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<-server side code on btn1 click and when click on button then will get browser capabilities accordingly->
<script runat="server">

    protected void btn_click(object s, EventArgs e)
    {
        //HttpBrowserCapabilities class used to gather information about browser running on client side
        //return type of HttpBrowserCapabilities is 
        //Request is specified to see page is to be requested
        //Browser property specify to get requesting about the client browser's capabilities
        HttpBrowserCapabilities hbc = Request.Browser;//Browser is also overloaded
        Response.Write("Type=" + hbc.Type + "<br>" +
            "Name=" + hbc.Browser + "<br>" +
            "Version=" + hbc.Version + "<br>" +
            "Major Version=" + hbc.MajorVersion + "<br>" +
            "Minor Version=" + hbc.MinorVersion + "<br>" +
            "Platform=" + hbc.Platform + "<br>" +
            "Supports Tables=" + hbc.Tables + "<br>" +
            "Supports cookies=" + hbc.Cookies + "<br>" +
            "Supports ActivX Controls=" + hbc.ActiveXControls + "<br>");
    }
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Detect your browser capabilities</title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:Button ID="btn1" runat="server" Text="Click here to see Browser Capabilities" OnClick="btn_click" />
    </form>
</body>
</html>

Ebook Download
View all
Learn
View all