chrome中的Request.Browser.Browser返回"IE" [英] Request.Browser.Browser in chrome returning "IE"

查看:160
本文介绍了chrome中的Request.Browser.Browser返回"IE"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在ASP.Net C#代码隐藏中执行如果浏览器是IE,并且低于版本9".

I am trying to do a "If browser is IE and is less than version 9" in ASP.Net C# codebehind.

但是,在chrome中,以下行:

However, In chrome, the following line:

if (Request.Browser.Browser == "IE" && Request.Browser.MajorVersion < 9)

输出为"IE"& 5个.尽管使用了Chrome v18.

Outputs as "IE" & 5 respectively. Despite using Chrome v18.

获取用户浏览器的正确用法是什么?还是这只是我正在使用的Chrome版本?这可能真的很简单,但是我确定这段代码以前可以工作

What is the correct usage for getting the users browser? Or is this just my version of Chrome playing up? It's probably really simple, but I'm sure this code worked previously

用户代理注册为: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.168 Safari/535.19

推荐答案

我有v19,但确实看到了正确的值.您确定没有任何仿真器(用户代理仿真器)或类似的东西...

I have v19 and i do see the correct value. Are you sure you don't have any emulator (user agent emulator) or something like this...

chrome 19

Browser Capabilities
Type = Chrome19
Name = Chrome
Version = 19.0
Major Version = 19
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 = False
Supports JavaScript = 3.0
Supports Java Applets = True
Supports ActiveX Controls = False
Supports JavaScript Version = 1.7

ie 8

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 = 3.0
Supports Java Applets = True
Supports ActiveX Controls = True
Supports JavaScript Version = 1.5

这是此输出的代码:

   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";

这篇关于chrome中的Request.Browser.Browser返回"IE"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆