In this post I will show you how to
get the browser information.To get the browser information the namespace
used for this is System.Windows.Browser. The BrowserInformation object
contains properties such as the name, product name, product version ,
browser version etc. Let us start with the example which will use to get
this information and display on the screen which I will share with you
at the end of the post I will use two screen shot one for the Internet
explorer and the second one for the Fire Fox.
For
this Example I have create one class with the name BrowserInfo which
has the properties like BrowserName , BrowerVersion, Platform,
ProductName, UserAgent of type string , IsCookiesEnabled of type Boolean
to indicate whether Cookies are enabled or not , BrowserMinorVersion
and BrowserMajorVersion are of type int.You can see the default
constructor of the BrowserInfo class which is used to initialize all the
properties of the class.
public BrowserInfo() { BrowserName = HtmlPage.BrowserInformation.Name; BrowserVersion = HtmlPage.BrowserInformation.BrowserVersion.ToString(); BrowserMajorVersion = HtmlPage.BrowserInformation.BrowserVersion.Major; BrowserMinorVersion = HtmlPage.BrowserInformation.BrowserVersion.Minor; IsCookiesEnabled = HtmlPage.BrowserInformation.CookiesEnabled; Platform = HtmlPage.BrowserInformation.Platform; ProductName = HtmlPage.BrowserInformation.ProductName; ProductVersion = HtmlPage.BrowserInformation.ProductVersion; UserAgent = HtmlPage.BrowserInformation.UserAgent; }
List 1
In the code you can see that
BrowserName property is assigned the value of the Name in the
BrowserInformation object which is the static member of the HtmlPage
static class which is reside in the System.Windows.Browser namespace.
The Name property of the BrowserInformation return the version of the
browser technology that the current browser is based on.The browser
technology name is typically different from the browser product name.
CookiesEnabled property of BrowserInformation object indicate whether
the browser supports cookies or not. The ProductName property of the
BrowserInformation object get the product name of the browser.The
browser product name is the familiar name of the browser, such as
"FireFox".
You can see the output of the two different browser One
for the internet explorer and second one is by using the Fire fox you
can see the different properties of the two browsers.Fire Fox |
Internet Explorer |
http://asimsajjad.blogspot.com/2010/11/browser-information-in-silverlight.html