How to Detect new Microsoft browser “Edge” in asp.net

后端 未结 5 1217
不知归路
不知归路 2020-12-18 11:14

In asp.net, using this construct, how might I detect the new Microsoft \"Edge\" browser?

    Dim wrkBrowser As String = \"\"
    Dim wrkBrowserType As String         


        
5条回答
  •  眼角桃花
    2020-12-18 12:02

    You need to check the UserAgent like this:

    if (Regex.IsMatch(HttpContext.Request.UserAgent, @"Edge\/\d+"))
    {
        wrkBrowser = "Edge"
    }
    

    If you're checking for multiple browsers be careful of the order you check as many browsers like to mention other browsers in their UserAgent string.

    This is Edge's current User Agent String:

    Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393

提交回复
热议问题