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
I know the answer is a little late but I searched all over the place and never found this and had to write it myself. The following code will allow the Request.Browser variables to return Edge and Edge Version instead of Chrome.
Adding the following snippet to a .browser file such as platform.browser in the App_Browsers folder will cause it to return Edge and the version.
<browser id="Edge" parentID="Chrome">
<identification>
<userAgent match="Edge/(?'version'(?'major'\d+)(?'minor'\.\d+))" />
</identification>
<capabilities>
<capability name="browser" value="Edge" />
<capability name="version" value="${version}" />
<capability name="majorversion" value="${major}" />
<capability name="minorversion" value="${minor}" />
</capabilities>
</browser>
As Joey mentioned, the User Agent string is what you want to look at. The properties of Request.Browser don't contain anything specific to Edge, but you can get the user agent string with HttpContext.Current.Request.UserAgent and use .IndexOf("Edge") to search it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With