In asp.net, using this construct, how might I detect the new Microsoft \"Edge\" browser?
Dim wrkBrowser As String = \"\"
Dim wrkBrowserType As String
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.
HttpContext.Current.Request.UserAgent.DefaultIfEmpty().Contains("Edge")
DefaultIfEmpty() is an extension method I wrote that ensures empty string if the string is null.
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"
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>
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