The best browser detection solution in ASP.NET 4.0

前端 未结 5 928
后悔当初
后悔当初 2020-12-29 06:08

I googled this topic and I came across with three different ways to configure browser capabilities: browscap.ini, browserCaps element in web.config and .browser files in App

相关标签:
5条回答
  • 2020-12-29 06:08

    Just so no one else goes down that dark path, be aware that even the jQuery team recommend that you DO NOT use jQuery.browser object:

    "The $.browser property is deprecated in jQuery 1.3"

    0 讨论(0)
  • 2020-12-29 06:16

    The best answer is feature detection, not browser detection! This is particularly true in the day where Firefox & Chrome are putting out releases ever few months and mobile browser use is growing. Use Modernizr (http://Modernizr.com) or an equivalent library to detect the features you are interested in.

    0 讨论(0)
  • 2020-12-29 06:22

    more info : http://msdn.microsoft.com/en-us/library/3yekbd5b.aspx Have you checked this :

        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"
            + "Supports JavaScript Version = " +
                browser["JavaScriptVersion"] + "\n";
    
        TextBox1.Text = s;
    
    0 讨论(0)
  • 2020-12-29 06:24

    I found a user agent parser from http://user-agent-string.info/ and it seems to be good enough for my purposes.

    0 讨论(0)
  • 2020-12-29 06:27

    So far I've used http://api.jquery.com/jQuery.browser/ for client side detection.

    0 讨论(0)
提交回复
热议问题