Queen
Queen

Reputation: 39

How to get user used browser name in .net core 2.0

I am using the code below:

Request.Headers["User-Agent"].ToString()

But it's giving me all browser details despite I only want the browser name.

Can anyone please help me with this problem?

Upvotes: 1

Views: 2770

Answers (1)

Guillaume S.
Guillaume S.

Reputation: 1545

User-Agent strings can come in various form, so it's better to use an API such as User Agent Parsing API to get better results.

You've not explained us why you want to detect the browser. But take some time to read MDN advices about/against browser detection:

Using the user agent to detect the browser looks simple, but doing it well is, in fact, a very hard problem. This document will guide you in doing this as correctly as possible.

Upvotes: 1

Related Questions