开发者

.NET User Agent parsing

Comparing the following User Agent strings for different browsers:

IE8

Mozilla/4.0 (compatible; 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; Media Center 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


I see there is consistency between Firefox and Chrome in displaying the Browser name (in bold in samples above), however IE shows it at an entirely different location in the string... How does the HttpBrowserCapabilitiesBase class parse this string? And how can I use this parser (or a custom one) to work with the Wurfl repository? (E.g. I cannot find User_agent="IE6" anywhere in the repository while this is u开发者_StackOverflowsed on Win mobile)

These are the variables from the .NET HttpBrowserCapabilitiesBase class in the Request object.

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

Firefox 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


Take a look at one of these resources:

  • WURFL
  • Browser Definition File Schema
  • Recent changes in Google Chrome's user agent settings

I once added my own browser definition file schema for exotic browsers (SeaMonkey)


I stumbled upon this question and did not see a reference to MDN Browser Detection using the User Agent. I found this to be very usefull when I was trying to detect browsers in ASP.NET because they even give a break down of what you should be able to parse for.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜