How to detect Browser capabilities in web applications using ASP.NET

Information about the browsers which the users use will be of good help, since you can tailor your application to work perfectly with different browsers. For example, for mobile devices you might want to give a less bandwidth oriented application.

Here I have used c# to give an example.

In order to do this, create an object of System.Web.HttpBrowserCapabilities and then use the properties of this object to get various data on the browsers.

For example,
System.Web.HttpBrowserCapabilities object = Request.Browser;

Then in order to get the name of the browser, use the code

string name = object.Browser;

This will store the name of the browser as a string in the variable name.

Other attributes include, Type(gives the type of the browser), MajorVersion(gives the major version), MinorVersion, Cookies( whether the browser supports cookies), VBScript etc.

Popular posts from this blog

How to increase Write/Copy/Read speed of Memory Card or Pen drive in Windows 7