Reputation: 5264
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?
Upvotes: 0
Views: 1307
Reputation: 31300
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.
Upvotes: 0
Reputation: 13509
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
Upvotes: 1