服务器端的 Internet Explorer 11 检测 [英] Internet explorer 11 detection on server side

查看:27
本文介绍了服务器端的 Internet Explorer 11 检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们都知道 IE11 检测不适用于服务器端语言,因为 Microsoft 已删除 IE/MSIE 浏览器指示,现在完全是Mozilla".

We all know that IE11 detection does not work with server side languages because Microsoft has removed the IE/MSIE browser indication and now is fully "Mozilla".

我也知道进行浏览器检测/版本是有风险的,但过去对我们都很好.

I also know that doing browser detection/version is risky but has served us all well in the past.

网站的一些要求如下:

必须使用特定版本的 Firefox 及更高版本必须使用特定版本的 chrome 及更高版本必须使用特定版本的 safari(一些低于和一些更新)必须使用 IE >= 8

must work with certain version of firefox and above must work with certain version of chrome and above must work with certain version of safari's (some below and some newer) must work with IE >= 8

所以这里是问题... IE11 在我的列表中表明它不受支持.我想从服务器(ASP.NET/MVC)的 Web 端支持它

so here is the problem... IE11 indicates on my list that it is not supported. I want to support it from the web side of things on the server (ASP.NET/MVC)

目前尚不清楚如何从服务器端检测到这一点.有人知道怎么做吗?

it is not clear exactly how to detect this from the server side. Does anyone know how?

这是现在在 IE 11 中显示的用户代理:

this is the user agent now being shown in IE 11:

"Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"

"Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"

rv:11.0 告诉我们它的 IE11,但是对它进行解析仍然意味着,例如,它可能是某个版本的 chrome,在这样的要求中甚至是 firefox 都不支持.

rv:11.0 tells us its IE11 however doing a parse on that will still mean that for example, it could be chrome of a certain version that is not supported in such a requirement or even firefox.

那么,在这里查看它是否确实是 IE 11 或更高版本的最佳方法是什么?

so, what is the best way here to see if it is indeed IE 11 or higher?

我不太确定从Trident"开始搜索,因为我不知道其他浏览器是否使用它.

I am not so sure about searching from "Trident" and onwards because I don't know if other browsers use that or not.

欢迎任何方向.

推荐答案

我通过使用下面的正则表达式解决了这个问题,因为我使用了一个淘汰系统来检查正在使用什么浏览器访问网站.

I solved this by using the Regex below after having a knock out system to check what browser is being used to access the site.

在这种情况下,即使浏览器IE"被检查并返回 false,我也会继续使用这个正则表达式并检查它是否与用户代理匹配:

in this case, even if the browser "IE" is checked and returns false, I go ahead and use this regex and check to see if it is a match against the user agent:

(?:(MS)?IEs+|Trident/7.0;.*s+rv:)(d+)

我希望这对某人有所帮助.我测试了它并且工作正常.我还将 rv 更改为 12 及更高版本,如果在 IE12 中将 rv 更改为 12,它也可以正常工作.

I hope this helps someone. I tested it and works fine. I also changed the rv to be 12 and upwards, and it works fine too in case if in IE12, they change rv to be 12.

这篇关于服务器端的 Internet Explorer 11 检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆