【问题标题】:.NET User Agent parsing.NET 用户代理解析
【发布时间】:2011-04-04 15:07:35
【问题描述】:

比较不同浏览器的以下用户代理字符串:

IE8

Mozilla/4.0(兼容;MSIE 8.0;Windows NT 6.1;WOW64;Trident/4.0;SLCC2;.NET CLR 2.0.50727;.NET CLR 3.5.30729;.NET CLR 3.0。 30729;媒体中心 PC 6.0;.NET4.0C;InfoPath.3;.NET4.0E)

Firefox 3

Mozilla/5.0(Windows;U;Windows NT 6.1;en-US;rv:1.9.2.16)Gecko/20110319 Firefox/3.6.16

Chrome 10

Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16


我看到 Firefox 和 Chrome 在显示浏览器名称方面是一致的(在上面的示例中以粗体显示),但是 IE 在字符串中的完全不同的位置显示它... HttpBrowserCapabilitiesBase 类如何解析这个细绳?以及如何使用此解析器(或自定义解析器)来处理 Wurfl 存储库?(例如,在 Win mobile 上使用时,我无法在存储库中的任何位置找到 User_agent="IE6")

这些是来自 .NET HttpBrowserCapabilitiesBase 类的 Request 对象中的变量。

IE8

Browser Capabilities Type = IE8
Name = IE
Version = 8.0
Major Version = 8
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

火狐3

Browser Capabilities Type = Firefox3
Name = Firefox
Version = 3.6
Major Version = 3
Minor Version = 6
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.8

Chrome 10

Browser Capabilities Type = Chrome10
Name = Chrome
Version = 10.0
Major Version = 10
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

【问题讨论】:

    标签: .net user-agent string-parsing


    【解决方案1】:

    查看以下资源之一:

    我曾经为异国情调的浏览器 (SeaMonkey) 添加了自己的浏览器定义文件架构

    【讨论】:

    • 在我的问题中,我指的是这些资源之一。他们如何匹配? user-agent 解析应该怎么做?
    【解决方案2】:

    我偶然发现了这个问题,但没有看到对 MDN Browser Detection using the User Agent 的引用。当我尝试在 ASP.NET 中检测浏览器时,我发现这非常有用,因为它们甚至可以分解您应该能够解析的内容。

    【讨论】:

      猜你喜欢
      • 2012-10-24
      • 1970-01-01
      • 2010-10-29
      • 1970-01-01
      • 2011-01-08
      • 1970-01-01
      • 2013-03-27
      • 1970-01-01
      相关资源
      最近更新 更多