I don't know much about MVC3, but you can set a custom header for all requests from AngularJS.
Then, on the server side, you just need to get this header and do what you want with the request from angular.
To make the custom header in AngularJS just do this:
angular.module('myModule', []) .config(['$httpProvider', function($httpProvider) { $httpProvider.defaults.headers.common["FROM-ANGULAR"] = "true"; }])
To use X-Requested-With, you must do this too:
$httpProvider.defaults.headers.common["X-Requested-With"] = 'XMLHttpRequest';
It is no longer installed by default because most of the community needs to remove this header in order to enable the CORS request.
Thomas Pons Sep 25 '13 at 9:52 on 2013-09-25 09:52
source share