为什么iPhone将谷歌Chrome视为Safari还将Mozilla Firefox视为Safari浏览器?

时间:2017-10-06 06:27:43

标签: c# mobile browser

我创建了一个代码,用于检查浏览器是否只能在Google Chrome上访问,并限制Mozilla Firefox。例如,我使用Android手机只想使用谷歌浏览器访问,如果iPhone或iPad谷歌浏览器有权访问该网站。但是,当检查浏览器是Chrome还是Mozilla时,它会被视为Safari。使用C#,工具。所以我调查它是否有一个很好用的独特属性,但遗憾的是没有。是否有一个很好的插件或库或框架来检测iPhone或Android浏览器。谢谢。

这适用于谷歌浏览器。

var userAgent = filterContext.HttpContext.Request.UserAgent?.ToLowerInvariant() ?? "";
"mozilla/5.0 (iphone; cpu iphone os 9_1 like mac os x) applewebkit/601.1.46 (khtml, like gecko) version/9.0 mobile/13b143 safari/601.1"

var userBrowser = filterContext.HttpContext.Request.Browser.Browser?.ToLowerInvariant() ?? "";
"safari"

var userBrowserTypeype = filterContext.HttpContext.Request.Browser.Type;
"Safari9"

var userBrowserVersion = filterContext.HttpContext.Request.Browser.Version;
"9.0"

var userBrowserMajorVersion = filterContext.HttpContext.Request.Browser.MajorVersion;
"9"

var userBrowserMinorVersion = filterContext.HttpContext.Request.Browser.MinorVersion;
0

var userBrowserPlatform = filterContext.HttpContext.Request.Browser.Platform;
"Unknown"

var userBrowserBeta = filterContext.HttpContext.Request.Browser.Beta;
false

var userBrowserCrawler = filterContext.HttpContext.Request.Browser.Crawler;
false

var userAol = filterContext.HttpContext.Request.Browser.AOL;
false

var userBrowserWin16 = filterContext.HttpContext.Request.Browser.Win16;
false

var userBrowserWin32 = filterContext.HttpContext.Request.Browser.Win32;
false

var userBrowserFrames = filterContext.HttpContext.Request.Browser.Frames;
true

var usBrowserTables = filterContext.HttpContext.Request.Browser.Tables;
true 

var userBrowserCookies = filterContext.HttpContext.Request.Browser.Cookies;
true

var userBrowserVbScript = filterContext.HttpContext.Request.Browser.VBScript;
false

这适用于Mozilla Firefox。

var userAgent = filterContext.HttpContext.Request.UserAgent?.ToLowerInvariant() ?? "";
"mozilla/5.0 (iphone; cpu iphone os 10_2_1 like mac os x) applewebkit/602.4.6 (khtml, like gecko) version/10.0 mobile/14d27 safari/602.1"

var userBrowser = filterContext.HttpContext.Request.Browser.Browser?.ToLowerInvariant() ?? "";
"safari"

var userBrowserTypeype = filterContext.HttpContext.Request.Browser.Type;
"Safari10"

var userBrowserVersion = filterContext.HttpContext.Request.Browser.Version;
"10.0"

var userBrowserMajorVersion = filterContext.HttpContext.Request.Browser.MajorVersion;
"10"

var userBrowserMinorVersion = filterContext.HttpContext.Request.Browser.MinorVersion;
0

var userBrowserPlatform = filterContext.HttpContext.Request.Browser.Platform;
"Unknown"

var userBrowserBeta = filterContext.HttpContext.Request.Browser.Beta;
false

var userBrowserCrawler = filterContext.HttpContext.Request.Browser.Crawler;
false

var userAol = filterContext.HttpContext.Request.Browser.AOL;
false

var userBrowserWin16 = filterContext.HttpContext.Request.Browser.Win16;
false

var userBrowserWin32 = filterContext.HttpContext.Request.Browser.Win32;
false

var userBrowserFrames = filterContext.HttpContext.Request.Browser.Frames;
true

var usBrowserTables = filterContext.HttpContext.Request.Browser.Tables;
true 

var userBrowserCookies = filterContext.HttpContext.Request.Browser.Cookies;
true

var userBrowserVbScript = filterContext.HttpContext.Request.Browser.VBScript;
false

1 个答案:

答案 0 :(得分:0)

这可能是由于iOS不允许其他浏览器引擎而不是Safari。

可悲的是,这迫使Chrome应用使用Safari的网络浏览器组件和用户代理。

了解更多about it here