0

I am testing an ASP.NET 3.5 app on 2 machines: one is a Windows 7 x64, and the other Windows Server 2008 x64.

When I use the same Chrome instance to open the websites on these 2 machines, I get different results on HttpBrowserCapabilities.Browser: on the Windows 7 machine I get browser.Name = "appleMac-safari", while on the Windows Server machine I get browser.Name = "applewebkit".

Both machine are have identical (AFAIK) installations of the asp.net app, same machine.config files, and the *.browser files are also identical on C:\Windows\Microsoft.NET\Framework64\v2.0.50727\CONFIG\Browsers

Any ideas why this discrepancy happens?

Oleks
  • 31,955
  • 11
  • 77
  • 132
rodbv
  • 5,214
  • 4
  • 31
  • 31

2 Answers2

1

Use the following to detect Chrome as it is more reliable

if (Request.UserAgent.Contains("Chrome"))
{
    ....
}

Where the UserAgent Value is:

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16
Nicholas Murray
  • 13,305
  • 14
  • 65
  • 84
0

I would look at the user agent string the browser is sending in. Chances are, the user agent string is not the same in that version of chrome on those 2 platforms. There are lots of little differences.

Also, I would add that, in most cases, server-side browser sniffing has very limited uses because, as you have seen, it is not particularly reliable and can be easily faked. If you are looking to style things differently or tweak some client-side behavior, using a javascript package like Modernizr to do feature detection is a much more robust way to go.

cdeszaq
  • 30,869
  • 25
  • 117
  • 173
  • Thanks. Will check Modernizr. But I am using the same browser instance (different tabs only) to access both sites, so it gotta be the same user agent, right? – rodbv Apr 15 '11 at 14:44
  • Ahh, yes, it sure _should_ be the same user agent. I misunderstood your question as to where the app was and where the browser was. It still wouldn't hurt to compare the useragent string, as well as any other headers the browser is sending to see if there is a difference in any way. – cdeszaq Apr 15 '11 at 14:52