📅  最后修改于: 2022-03-11 14:48:52.707000             🧑  作者: Mango
// 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);
}
}