devxlogo

Check if an HttpRequest is an Ajax Request

Check if an HttpRequest is an Ajax Request

A quick way to check if an HTTP Request is an Ajax request is by examining the X-Requested-With Header value.

Please see below:

bool isAjaxRequest = request.Headers["X-Requested-With"] != null && request.Headers["X-Requested-With"] == "XMLHttpRequest";

devx-admin

Share the Post: