Cara Mendapatkan Informasi Browser Pengguna di .NET Core
// ASP.NET Core Detection with Responsive View for identifying details about client device, browser, engine, platform, & crawler. Responsive middleware for routing base upon request client device detection to specific view.
public class MyCustomMiddleware
{
private readonly RequestDelegate _next;
public MyCustomMiddleware(RequestDelegate next)
{
_next = next ?? throw new ArgumentNullException(nameof(next));
}
public async Task InvokeAsync(HttpContext context, IDetectionService detection)
{
if(detection.Device.Type == Device.Mobile)
context.Response.WriteAsync("You are Mobile!");
await _next(context);
}
}
code fighter