How to get user Browser name ( user-agent ) in Asp.net Core?

For me Request.Headers["User-Agent"].ToString() did't help cause returning all browsers names so found following solution.

Installed ua-parse.

In controller using UAParser;

var userAgent = HttpContext.Request.Headers["User-Agent"];
var uaParser = Parser.GetDefault();
ClientInfo c = uaParser.Parse(userAgent);

after using above code was able to get browser details from userAgent by using c.UA.Family + " " + c.UA.Major +"." + c.UA.Minor You can also get OS details like c.OS.Family;

Where c.UA.Major is a browser major version and c.UA.Minor is a browser minor version.


I think this was an easy one. Got the answer in Request.Headers["User-Agent"].ToString()


userAgent = Request.Headers["User-Agent"]; 

https://code.msdn.microsoft.com/How-to-get-OS-and-browser-c007dbf7 (link not live) go for 4.8

https://docs.microsoft.com/en-us/dotnet/api/system.web.httprequest.useragent?view=netframework-4.8