Detect Browser Types And Browser Capabilities In ASP.NET.
In this session will learn strength of HttpBrowserCapabilities , which allow us to track client browser information to make our application user friendly on web. We can track browser version, type, name and may more. A small example will describe you more.
Simply you have to make a page webcheck.aspx and paste all given code:
<%@ Page Language="C#" Title="Browser Capabilities" %>
<!DOCTYPE html>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
System.Web.HttpBrowserCapabilities browser = Request.Browser;
string s = "<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 />"
+ "Supports JavaScript Version = " +
browser["JavaScriptVersion"] + "<br />";
lblbrowser1.Text = s;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div >
<h2>Browser Capabilities</h2>
<asp:Label ID="lblbrowser1" runat="server" Text=""></asp:Label>
</div>
</form>
</body>
</html>
Hope you will enjoy with this, demo. :)
In this session will learn strength of HttpBrowserCapabilities , which allow us to track client browser information to make our application user friendly on web. We can track browser version, type, name and may more. A small example will describe you more.
Simply you have to make a page webcheck.aspx and paste all given code:
<%@ Page Language="C#" Title="Browser Capabilities" %>
<!DOCTYPE html>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
System.Web.HttpBrowserCapabilities browser = Request.Browser;
string s = "<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 />"
+ "Supports JavaScript Version = " +
browser["JavaScriptVersion"] + "<br />";
lblbrowser1.Text = s;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div >
<h2>Browser Capabilities</h2>
<asp:Label ID="lblbrowser1" runat="server" Text=""></asp:Label>
</div>
</form>
</body>
</html>
Hope you will enjoy with this, demo. :)