ASP.NET - Find if a Request is of type Ajax

By [)ia6l0 iii

You can check the contenttype of the request, and figure out if the request is an Ajax request

The following code sample can be used.

bool isAjaxRequest = false;
isAjaxRequest = request.Headers.Get(""x-microsoftajax"") ?? """")
                .Equals(""delta=true"", StringComparison.OrdinalIgnoreCase);

Related FAQs

Use the "IsSecureConnection" property of the HttpRequest object to find if a Request is from a HTTP or HTTPS connection
Use the Proxy property of the Http Web Request to specify proxy.
You can read the contents of a web page into a string using the HTTPWebRequest class
Use the following code snippet to download an image from an URL.
You can read the contents of a web page into a string using the WebClient class.
Use the Credentials property of the Http Web Request to specify Credentials.
ASP.NET - Find if a Request is of type Ajax  (1161 Views)