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"]));
}