如何在MVC 5应用程序中检测Safari浏览器

发布于 2025-02-04 09:36:27 字数 429 浏览 1 评论 0原文

我有一个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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文