[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 668
  • Last Modified:

browser detection not working with changing IE browser document mode

I have to include an additional js script for IE7.  I am using the IE7 developer tools to test different browsers.  If you open dev tools (press F12), then there is a tab where you can switch between IE9, 8, 7.  

No matter what this setting is on, I get the same info in C# using the function below.  (For some reason it always shows IE7.  When I try to find the version using JavaScript, I see the same version (9.0) no matter what the switch is on.

Question: How can I detect the browser and test using the IE document mode tab?

Output from js
console.log(navigator.userAgent);
LOG: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; MS-RTC LM 8; .NET CLR 1.1.4322; .NET4.0C; .NET4.0E; InfoPath.2)

Open in new window


Output from C#
Browser Capabilities
Type = IE7
Name = IE
Version = 7.0
Major Version = 7
Minor Version = 0
Platform = WinNT
Is Beta = False
Is Crawler = False
Is AOL = False
Is Win16 = False
Is Win32 = True
Supports Frames = True
Supports Tables = True
Supports Cookies = True
Supports VBScript = True
Supports JavaScript = 1.2
Supports Java Applets = True
Supports ActiveX Controls = True

Open in new window


public string GetBrowserInfo()
{
    System.Web.HttpBrowserCapabilities browser = Request.Browser;
    string browserString = "Browser Capabilities<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>";
    return browserString;
}

Open in new window

0
jackjohnson44
Asked:
jackjohnson44
1 Solution
 
jackjohnson44Author Commented:
I found the issue.  There are two buttons on the developer tools.  Browser Mode is sent to the server.  Document Mode is on the client.  If you change Browser Mode, you can detect it in C#, Document mode you can't.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now