using Microsoft.AspNetCore.Http; namespace Connected; public static class RuntimeExtensions { public static bool IsAjaxRequest(this HttpRequest request) { if (request is null) throw new ArgumentNullException(nameof(request)); if (request.Headers is not null && request.Headers.ContainsKey("X-Requested-With")) return string.Equals(request.Headers["X-Requested-With"], "XMLHttpRequest", StringComparison.OrdinalIgnoreCase); return false; } }