gpt4 book ai didi

c# - Chrome 中的 Request.Browser.Browser 返回 "IE"

转载 作者:太空宇宙 更新时间:2023-11-03 20:26:04 28 4
gpt4 key购买 nike

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

但是,在 chrome 中,以下行:

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

输出分别为“IE”和 5。尽管使用 Chrome v18。

获取用户浏览器的正确用法是什么?或者这只是我的 Chrome 版本?这可能真的很简单,但我确信这段代码以前有效

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

最佳答案

我有 v19,我确实看到了正确的值。你确定你没有任何模拟器(用户代理模拟器)或类似的东西......

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

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

关于c# - Chrome 中的 Request.Browser.Browser 返回 "IE",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10597531/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com