Skip to main content

isAjaxRequest issue When Angular Used

isAjaxRequest
         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

Popular posts from this blog

Jquery notification plugins PNotify

Demo More

MVC (Model View Controller)

MVC pattern overview MVC offers architectural benefits over standard JavaScript — it helps you write better organized, and therefore more maintainable code. This pattern has been used and extensively tested over multiple languages and generations of programmers. MVC is composed of three components: Model Model is where the application’s data objects are stored. The model doesn’t know anything about views and controllers. When a model changes, typically it will notify its observers that a change has occurred. View View is what's presented to the users and how users interact with the app. The view is made with HTML, CSS, JavaScript and often templates. This part of your Chrome App has access to the DOM. For example, in the above todo list web app, you can create a view that nicely presents the list of todo items to your users. Users can also enter a new todo item through some input format; however, the view doesn’t know how to update the model because that’s th...

json2csharp generate c# classes from json

               Demo More