views:

159

answers:

1

For the user agent string

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)

HttpContext.Current.Request.Browser.MajorVersion returns 3 and HttpContext.Current.Request.Browser.MinorVersion returns 5. So far so good.

However for this user agent string (seen in the wild by one of my users)

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 (CK-Finbu.com) Firefox/3.6 (.NET CLR 3.5.30729)

HttpContext.Current.Request.Browser.MajorVersion returns 1 and HttpContext.Current.Request.Browser.MinorVersion returns 9. It looks like ASP.NET has picked up the numbers from the CVS tag info rather than the browser version.

Does this mean that ASP.NET's user agent parsing is broken?

+1  A: 

Seems you'll need to tweak your mozilla.browser file (in %windir%\Microsoft.NET\Framework\v2.0.50727\CONFIG\Browsers\ folder).

Around line 188, you'll see this (regex to match Firefox browser):

"Gecko\/\d+ Firefox\/(?'version'(?'major'\d+)(?'minor'\.[.\d]*))"

Should be

"Gecko\/\d+(?: \S+)? Firefox\/(?'version'(?'major'\d+)(?'minor'\.[.\d]*))"
Rubens Farias
So SELECT is broken. My colleague has this user agent string, which looks like the standard one for Firefox on Ubuntu. It won't match that regex either.Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.9.1.7) Gecko/20100106 Ubuntu/9.10 (karmic) Firefox/3.5.7
Alex Scordellis
Mozilla have a document about that: https://developer.mozilla.org/User_Agent_Strings_Reference ; according this document, that UA is wrong
Rubens Farias