检测浏览器类型

时间:2011-07-01 15:04:06

标签: asp.net cross-browser browser-testing

Togeather在我的asp.net应用程序中出现错误报告,我也在检索浏览器信息。例如,我经常遇到特定的错误:

Type = Mozilla
Name = Mozilla
Version = 5.0
Major Version = 5
Minor Version = 0
Platform = Unknown
Is Beta = False
Is Crawler = False
Is AOL = False
Is Win16 = False
Is Win32 = False
Supports Frames = False
Supports Tables = False
Supports Cookies = False
Supports VBScript = False
Supports JavaScript = False
0.0
Supports Java Applets = False
Supports ActiveX Controls = False

我的第一个想法是firefox,但我在某些错误中得到了firefox,所以我不确定上述信息中的确切浏览器是什么?

由于

2 个答案:

答案 0 :(得分:3)

TRY BELOW

Response.Write(Request.ServerVariables("HTTP_USER_AGENT")) 

//获取访客的浏览器名称

if (Request.ServerVariables["HTTP_USER_AGENT"].Contains("MSIE"))
  browser = "Internet Explorer";
if (Request.ServerVariables["HTTP_USER_AGENT"].Contains("FireFox"))
  browser = "Fire Fox";
if (Request.ServerVariables["HTTP_USER_AGENT"].Contains("Opera"))
  browser = "Opera";

答案 1 :(得分:0)

试试这个,它会为您提供有关浏览器的数据: System.Web.HttpBrowserCapabilities browser = Request.Browser;