isAjaxRequest
Determines whether the specified HTTP request is an AJAX request.
Namespace: System.Web.Mvc
Assembly: System.Web.Mvc (in System.Web.Mvc.dll)
Determines whether the specified HTTP request is an AJAX request.
Namespace: System.Web.Mvc
Assembly: System.Web.Mvc (in System.Web.Mvc.dll)
Syntax :
public static bool IsAjaxRequest( this HttpRequestBase request )
Parameters
- request
- Type: System.Web.HttpRequestBase
The HTTP request.Return Value
Type: System.Boolean
true if the specified HTTP request is an AJAX request; otherwise, false.When we try to send request from AngularJs, this method always return false. Why is this happening is, the angular not set the header X-Request-With property. So we should set it. For that,var app = angular.module("app", []);app.config(['$httpProvider', function ($httpProvider) {$httpProvider.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';}]);this wil configure out http provider header all the time.

Comments
Post a Comment