Answer

The solution is in depended from MVC.NET framework and universal across server-side technologies. Most modern AJAX applications utilize XmlHTTPRequest to send async request to the server. Such requests will have distinct request header:

X-Requested-With = XMLHTTPREQUEST

AJAX GET Request

MVC.NET provides helper function to check for ajax requests which internally inspects X-Requested-With request header to set IsAjax flag.

HelperPage.IsAjax Property
Gets a value that indicates whether Ajax is being used during the request of the Web page.

Namespace: System.Web.WebPages
Assembly: System.Web.WebPages.dll

However, same can be achieved by checking requests header directly:

Request["X-Requested-With"] == "XmlHttpRequest"







Answers and Comments