Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/258.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 当兼容模式打开时,如何确定正确的浏览器版本_C#_.net_Asp.net_Internet Explorer - Fatal编程技术网

C# 当兼容模式打开时,如何确定正确的浏览器版本

C# 当兼容模式打开时,如何确定正确的浏览器版本,c#,.net,asp.net,internet-explorer,C#,.net,Asp.net,Internet Explorer,我需要确定用户正在使用哪个版本的浏览器,但是默认情况下,整个公司的兼容模式是打开的 在服务器端脚本中,如何确定真正的浏览器版本 谢谢 更新 我已经使用document.documentMode正确显示了IE版本,但是我不知道如何将其传递到服务器端以便使用。将为您提供完整的浏览器信息,您可以在其中检查版本、浏览器名称、浏览器类型等 Request.Browser.Version // Return complete browser version infor Request.Browser.Bro

我需要确定用户正在使用哪个版本的浏览器,但是默认情况下,整个公司的兼容模式是打开的

在服务器端脚本中,如何确定真正的浏览器版本

谢谢

更新 我已经使用document.documentMode正确显示了IE版本,但是我不知道如何将其传递到服务器端以便使用。

将为您提供完整的浏览器信息,您可以在其中检查版本、浏览器名称、浏览器类型等

Request.Browser.Version // Return complete browser version infor
Request.Browser.Browser // If browser is IE then it will return **IE**

javascript中的document.documentMode就是解决方案

<script>
alert(document.documentMode);
<script>

警报(document.documentMode);

您可以为特定的web应用程序关闭兼容模式,而不是对抗兼容模式。我们在我们所有的网站上都这样做,因为兼容性模式确实把很多事情搞砸了


在服务器上使用HttpContext.Current.Request.UserAgent如果在客户端,则使用user navigator.UserAgent 下面的说明ie7没有trident关键字,但ie8是trident/4,IE5是trident/5

首先查找MSIE x.x,如果x.x为7,则查找三叉戟/y.y。如果三叉戟缺失,则查找IE7如果y.y为4,则查找IE8;如果y.y为5,则查找ie9;如果y.y为6,则查找ie10


可能与@Michael重复,但我如何在服务器端执行该操作?我将结果用作Linq查询的一部分。当浏览器使用兼容模式时,这不起作用。即使使用IE9,Request.Browser.Version仍返回7.0。这就是我想要得到的around@Matt检查这个,我有一个裂缝,但我不能使它工作。我将进一步研究它,因为它是一个比我目前拥有的更优雅的版本。在我的情况下,当我在兼容模式下使用IE8时,它也会提醒7