如何在MVC 5应用程序中检测Safari浏览器
我有一个MVC 5应用程序(不是核心,而是.NET框架),其中我只想添加Safari浏览器的支票,但是问题是,当我从请求中获取用户代理时,我正在将所有浏览器安装在PC上。
我得到以下值:
Mozilla/5.0(Windows NT 10.0; WOW64)AppleWebkit/537.36(Khtml,喜欢 Gecko)Chrome/102.0.5005.63 Safari/537.36
,但实际上我正在通过Chrome打电话。这是我获得的价值的方式,
var userAgent = filterContext.HttpContext.Request.UserAgent;
我也尝试从标题(这是同一件事)中获得值。
如何添加Safari浏览器的支票?
I have a mvc 5 application (not core but .net framework) where I am trying to add a check for Safari browser only but the issue is I am getting all browsers installed on my pc when i get User-Agent from request.
I am getting the following value:
Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like
Gecko) Chrome/102.0.5005.63 Safari/537.36
But actually I am calling through chrome. Here is how I am getting the value
var userAgent = filterContext.HttpContext.Request.UserAgent;
I've also tried getting the value from header (which is the same thing) e.g Request.Headers["User-Agent"] but still same result.
How can I add a check for Safari browser?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论