Detecting a browser type

寵の児 提交于 2019-12-11 07:14:18

问题


Togeather with error reporting in my asp.net app, I am also retreiving browser information. For example I am getting specific error a lot:

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

My first idea was firefox, but I aslo get firefox in certain erros, so I am not sure what is the exact browser from the information above?

Thanks


回答1:


TRY BELOW

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

// Getting Browser Name of Visitor

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";



回答2:


Try out this, it will get you the data you need about your browser: System.Web.HttpBrowserCapabilities browser = Request.Browser;



来源:https://stackoverflow.com/questions/6549706/detecting-a-browser-type

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!