If your goal is to know the user's browser and some information about their device then you could make a test with the UAParser
It could return browser names and OS-related information that could help you predict the device type.
I tried to make a test using.Net Core 6 project and it works. So it should not have any issue with the.Net Core 3.1 project.
You could refer to the example below.
Index.cshtml
@page
@model IndexModel
@{
ViewData["Title"] = "Home page";
}
<div class="text-center">
<h1 class="display-4">Welcome</h1>
<p>Learn about <a href="https://learn.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
<p>You are using @Model.Message</p>
</div>
Index.cshtml.cs
public string Message { get; set; }
public void OnGet()
{
var userAgent = HttpContext.Request.Headers["User-Agent"];
var uaParser = Parser.GetDefault();
ClientInfo c = uaParser.Parse(userAgent);
this.Message = c.ToString();
}
Output in different browsers:
Further, you could make a tests with different devices to check for the results.
Reference is taken from here .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.