In IE8 and 9, I get the following JavaScript error when I make a CORS web client call:
Error: Access is denied. { [functions]: , description: "Access is denied.", message: "Access is denied.", name: "Error", number: -2147024891 }
I installed my WebApi as described here http://www.asp.net/web-api/overview/security/enabling-cross-origin-requests-in-web-api
Thus, WebApi contains:
public static class WebApiConfig { public static void Register(HttpConfiguration config) { config.EnableCors(new EnableCorsAttribute("*", "*", "*")); [...]
My test AngularJS application:
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ng="http://angularjs.org" ng-app="app"> <head> <title>test</title> <script src="Scripts/angular.js"></script> <script src="app.js"></script> </head> <body> <div ng-controller="testController as vm"> {{vm.test}} {{vm.data}} </div> </body> </html>
app.js:
var app = angular.module('app'); app.controller('testController', function ($http) { var vm; vm = this; vm.test = "bla non no "; vm.data = null; $http.defaults.headers.common['Authorization'] = 'a token' return $http({ method: 'GET', data: null, url: 'http://webapi.com/api/controller/getactionmethod/', }, function (data) { console.log("bla"); }).success(function (data, status, headers, config) { console.log("bla a"); vm.data; }); });
The above code / webapi calls work with chrome and IE 10. IE10 fingerprints:
SEC7118: XMLHttpRequest for http://webapi.com/api/controller/getactionmethod/ requires Cross Resource Resource (CORS). SEC7119: XMLHttpRequest for http://webapi.com/api/controller/getactionmethod/ requires a preview of CORS.
I am really stuck and don't know what I can try. Any ideas?