Follow in Twitter & Facebook


Like in Facebook

Powered By Blogger Widgets

Free Download

FREE Tools


Tuesday, September 4, 2012

Retrieve browser details using C#.Net in Asp.net

In this article we will discuss how to get browser details like browser name, browser version etc using C#.Net. You can also check my last article on how to Disable right click by using jQuery in asp.net.

C#.Net provides HttpBrowserCapabilities class to interact with browser properties. This class present in System.Web namespace. So before using the HttpBrowserCapabilities we need to import the namespace.

Full code:
lblBrowserDetails.Text = "Browser name: " + Request.Browser.Browser
            + " Browser Type: " + Request.Browser.Type
            + " Browser Version :" + Request.Browser.Version
            + " Browser Major Version: " + Request.Browser.MajorVersion
            + " Browser Minor Version: " + Request.Browser.MinorVersion
            + " Is Browser in Beta version? " + Request.Browser.Beta;

The output will be like below:
IE:
Browser name: IE Browser Type: IE8 Browser Version :8.0 Browser Major Version: 8 Browser Minor Version: 0 Is Browser in Beta version? False

Firefox:
Browser name: Firefox Browser Type: Firefox15 Browser Version :15.0 Browser Major Version: 15 Browser Minor Version: 0 Is Browser in Beta version? False

Chrome:
Browser name: Chrome Browser Type: Chrome21 Browser Version :21.0 Browser Major Version: 21 Browser Minor Version: 0 Is Browser in Beta version? False

Like this also there are other properties available and we can access.
Reference from:
http://msdn.microsoft.com/en-us/library/3yekbd5b(v=vs.100).aspx

Also you can check SharePoint articles and SharePoint jobs.




0 on: "Retrieve browser details using C#.Net in Asp.net"