IsAjaxRequest

public static bool IsAjaxRequest(this HttpRequest request)
{
    if (request == null)
    {
        return false;
    }
   
    return ("XMLHttpRequest" == request["X-Requested-With"]) || ((request.Headers != null) && ("XMLHttpRequest" == request.Headers["X-Requested-With"]));
}

你可能感兴趣的:(IsAjaxRequest)