Get IE version using c#

Posted by Nithyarani under C# on 2/8/2012 | Points: 10 | Views : 6386 | Status : [Member] | Replies : 1
Hi

I want to get the Internet Explore Version. For that i was using the bellow code.

float rva = -1;
string z = Request.Browser.Type;
ArrayList a = Request.Browser.Browsers;
string b = Request.Browser.Version;
// Will the version of IE or a -1 indicating the use of another browser.
System.Web.HttpBrowserCapabilities browser = Request.Browser;
string x= browser.MSDomVersion.ToString();
string y = browser.W3CDomVersion.ToString();
if (browser.Browser == "IE")
rva = (float)(browser.MajorVersion + browser.MinorVersion);

in this code i was getting the bellow issue.

I was using IE9. But i was getting the IE version as IE7. Why this is happening?

Kindly anyone can help me in this.

Thanks,
Nithya

Nithya Rani


Responses

Posted by: Ogipansrk on: 2/8/2012 [Member] Starter | Points: 25

Up
0
Down
Nitya Rani,

I think you are using internal browser option instead of Internet explorer.
Anyway , the below code works
System.Web.HttpBrowserCapabilities browser = Request.Browser;
string s = "Browser Capabilities\n"
+ "Type = " + browser.Type + "\n"
+ "Name = " + browser.Browser + "\n"
+ "Version = " + browser.Version + "\n"
+ "Major Version = " + browser.MajorVersion + "\n"
+ "Minor Version = " + browser.MinorVersion + "\n"
+ "Platform = " + browser.Platform + "\n"
+ "Is Beta = " + browser.Beta + "\n"
+ "Is Crawler = " + browser.Crawler + "\n"
+ "Is AOL = " + browser.AOL + "\n"
+ "Is Win16 = " + browser.Win16 + "\n"
+ "Is Win32 = " + browser.Win32 + "\n"
+ "Supports Frames = " + browser.Frames + "\n"
+ "Supports Tables = " + browser.Tables + "\n"
+ "Supports Cookies = " + browser.Cookies + "\n"
+ "Supports VBScript = " + browser.VBScript + "\n"
+ "Supports JavaScript = " +
browser.EcmaScriptVersion.ToString() + "\n"
+ "Supports Java Applets = " + browser.JavaApplets + "\n"
+ "Supports ActiveX Controls = " + browser.ActiveXControls
+ "\n"
+ "Supports JavaScript Version = " +
browser["JavaScriptVersion"] + "\n";

TextBox1.Text = s;

Hope diz helps !!

Ogipansrk

Nithyarani, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response