wayfarer wayfarer - 16 days ago 5
ASP.NET (C#) Question

How to Detect new Microsoft browser "Edge" in asp.net

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

Dim wrkBrowser As String = ""
Dim wrkBrowserType As String = HttpContext.Current.Request.Browser.Type
If InStr(wrkBrowserType, "Chrome") <> 0 Then
wrkBrowser = "Chrome"
End If
If InStr(wrkBrowserType, "MSIE") <> 0 Then
wrkBrowser = "IE"
End If
If InStr(wrkBrowserType, "FireFox") <> 0 Then
wrkBrowser = "FF"
End If

Answer

I am not an adept in anything .NET, but reading your code, it seems to me that the value returned by

HttpContext.Current.Request.Browser.Type

Is a user agent.

You can find information about the user-agent for Edge at this page.

User-agent for edge:

Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36 Edge/12.0

Note that the value can change based on mobile, xbox, etc.

So in your case, try doing a check on "Edge"

Comments