VadVergasov_Programming/5/Lab_153503_Verhasau/Lab_153503_Verhasau/Extensions/HttpRequestExtensions.cs
namespace Lab_153503_Verhasau.Extensions;

public static class HttpRequestExtensions
{
    public static bool IsAjaxRequest(this HttpRequest request)
    {
        if (request == null)
        {
            throw new ArgumentNullException(nameof(request));
        }

        if (request.Headers != null)
        {
            return request.Headers["X-Requested-With"] == "XMLHttpRequest";
        }
        return false;
    }
}
