如何使用ASP.NET&C#从服务器端确定浏览器类型?

前端之家收集整理的这篇文章主要介绍了如何使用ASP.NET&C#从服务器端确定浏览器类型?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想使用C#在ASP.NET页面上确定代码隐藏文件中的浏览器类型。

如果是IE 6.0,我必须执行某些代码行。

如何确定浏览器类型?

解决方法

您可以使用Request.Browser来识别浏览器信息。这些MSDN 1& 2文章给出了更多的信息。
System.Web.HttpBrowserCapabilities browser = Request.Browser;
string s = "Browser Capabilities\n"
    + "Type = "                    + browser.Type + "\n"
    + "Name = "                    + browser.Browser + "\n"
    + "Version = "                 + browser.Version + "\n"
    + "Major Version = "           + browser.MajorVersion + "\n"
    + "Minor Version = "           + browser.MinorVersion + "\n"
    + "Platform = "                + browser.Platform + "\n"
    + "Is Beta = "                 + browser.Beta + "\n"
    + "Is Crawler = "              + browser.Crawler + "\n"
    + "Is AOL = "                  + browser.AOL + "\n"
    + "Is Win16 = "                + browser.Win16 + "\n"
    + "Is Win32 = "                + browser.Win32 + "\n"
    + "Supports Frames = "         + browser.Frames + "\n"
    + "Supports Tables = "         + browser.Tables + "\n"
    + "Supports Cookies = "        + browser.Cookies + "\n"
    + "Supports VBScript = "       + browser.VBScript + "\n"
    + "Supports JavaScript = "     + 
        browser.EcmaScriptVersion.ToString() + "\n"
    + "Supports Java Applets = "   + browser.JavaApplets + "\n"
    + "Supports ActiveX Controls = " + browser.ActiveXControls 
          + "\n";

猜你在找的asp.Net相关文章