AspNetCore.Docs/aspnet/whitepapers/add-mobile-pages-to-your-as.../samples/sample6.cs

7 lines
292 B
C#

public override string GetVaryByCustomString(HttpContext context, string custom)
{
if (string.Equals(custom, "isMobileDevice", StringComparison.OrdinalIgnoreCase))
return context.Request.Browser.IsMobileDevice.ToString();
return base.GetVaryByCustomString(context, custom);
}