问题描述
我创建了一个代码,用于检查浏览器是否只能在Google Chrome上访问,并限制Mozilla Firefox.例如,我使用的Android手机仅允许使用Google Chrome进行访问,并且如果iPhone或iPad Google Chrome有权访问该网站.但是,当检查浏览器是Chrome还是Mozilla时,它将被视为Safari.使用C#工具.因此,如果有一个独特的属性可以很好地使用,但不幸的是没有一个,我将对其进行调查.是否有一个好的插件或库或框架可以检测iphone或android浏览器.谢谢.
I create a code that checks if the browser is accessible only on Google Chrome and limit Mozilla Firefox. For example, I use an Android phone I want to give access only using Google Chrome and if an iPhone or iPad Google Chrome have privileges to access the website. But when check if the browser is Chrome or Mozilla it treated as Safari. Using the C#, tools. So I investigate it if there's a unique property that is good to use but sadly none. Is there a good plugin or libraries or framework to detect an iphone or android browser. Thank you.
这是针对Google Chrome浏览器的.
This is for Google Chrome.
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.
This is for 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
推荐答案
这可能是因为iOS不允许使用除Safari之外的其他浏览器引擎.
That is probably due to that iOS does not allow other browser engines than Safari.
遗憾的是,这迫使Chrome应用程序使用Safari的网络浏览器组件和用户代理.
Sadly, this forces the Chrome app to use Safari's web browser component and user agent.
了解更多信息在此处对其进行
这篇关于为什么iPhone将Google Chrome浏览器作为Safari以及将Mozilla Firefox浏览器作为Safari浏览器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!