This is really odd, I'm using the HttpContext.Request.Browser.Browser property to check from which browser the request came for.
When using chrome, the value is Chrome
When using firefox, the value is Firefox
When using Edge, the value is Chrome
Is it a known bug in HttpContext?
What is the most accurate way to detect IE\Edge users? I've seen many JS codes which checks the user_agent value, but it keeps changing with every IE version so it is really hard to know which code is updated, and which one isn't.
Maybe there's some good JS library for that purpose that someone can please recommend?
This Method worked fine for me
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. At that time Check the Below Condition also
 Request.Browser.Browser == "Chrome" 
                        I was facing the same issue and I figured out the root cause of it and also able to resolve it.
Solution is to increase the userAgentCacheKeyLength in Web.config, as follows:
<system.web>
    <browserCaps userAgentCacheKeyLength="256" />
</system.web>
By default the value for userAgentCacheKeyLength is 64.
What happens is that IIS cached the user agent value up to the length defined in userAgentCacheKeyLength (which is 64 by default). So if you hit the first request with Chrome IIS stores first 64 characters of user agent value of Chrome in cache. Now the next time if you hit the request from Edge, IIS matches the first 64 characters and it's similar to Chrome's so IIS returns the browser value as Chrome.
If you increase the value to 256, IIS will be able to store the full value of user agent hence it will distinguish Chrome and Edge browsers accurately always.
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