In IE8 und 9 ich folgende JavaScript-Fehler bin immer, wenn ich einen CORS WebAPI Anruf mache:IE9, IE8 mit AngularJS CORS gibt „Zugriff verweigert“ - ASP.NET WebAPI
Error: Access is denied.
{
[functions]: ,
description: "Access is denied.",
message: "Access is denied.",
name: "Error",
number: -2147024891
}
I gesetzt up my WebAPI wie hier beschrieben http://www.asp.net/web-api/overview/security/enabling-cross-origin-requests-in-web-api
So ist die WebAPI enthält:
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
config.EnableCors(new EnableCorsAttribute("*", "*", "*"));
[...]
Mein Test AngularJS App:
<!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;
});
});
Der obige Code/WebAPI Arbeiten mit Chrom und IE 10. IE10 druckt ruft:
SEC7118: XMLHttpRequest für http://webapi.com/api/controller/getactionmethod/ erforderlich Cross-Origin Resource Sharing (CORS). SEC7119: XMLHttpRequest für http://webapi.com/api/controller/getactionmethod/ erforderlich CORS Preflight.
Ich bin wirklich fest und weiß nicht, was ich sonst noch versuchen kann. Irgendwelche Ideen?
http://stackoverflow.com/questions/10232017/ie9-jquery-ajax-with-cors-returns-access-is-denied – epascarello
Ich benutze angularjs nicht jQuery. – Briefkasten
IE8 und IE9 unterstützen den Standard CORS XHR nicht. Siehe meine Antwort auf diese Frage für weitere Informationen http://stackoverflow.com/questions/25141650/xdomainrequest-vs-xmlhttprequest – MrCode