javascript - IE9,IE8 with AngularJS CORS returns âAccess is deniedâ - ASP.NET WebApi -
In IE8 and 9, I am receiving the following JavaScript error when I am calling a Corus Webp: WebApi is described as Then WebApi includes: My test AngularJS app: app.js: The above code / webpi call works with Chrome and IE 10. IE 10 prints: SEC7118: XMLHttpRequest for Essential Cross Origin Resource Sharing (CORS) . SEC7119: XMLHttpRequest required for CORS preflight. I'm really stuck and do not know any more thoughts I can try? I had the same problem with IE8 / 9 (instead of ASP.NET, Django backend) when CORS Make the request. There are several ways to solve this problem. The easiest and fastest solution for me was to use polyfil, this polyfil normal COVER XMLHttpXEsts will be swapped on IE8 / 9 for XDR Include hooks already on your site and add: There are several other solutions:
public static class WebApiConfig {public static zero registration (HTTP configuration configuration) {config.EnableCors (New EnableCorsAttribute ("*", " * "," * ")); [...]
var app = angular Module ('app'); App.controller ('testcontroller', function ($ http) {var vm; vm = this; vm.test = "bla no no"; vm.data = null; $ http.defaults.headers.common ['authorization'] = 'A token' return $ http ({method: 'GET', data: faucet, url: 'http://webapi.com/api/controller/getactionmethod/',}, function (data) {console.log ( "Bla");}). Success (function (data, position, header, config) {console.log ("bla a"); vm.data;});});
xhook.before (function (request, callback) {// SPEP browsers that do not use XDR If (! Window.XDomainRequest) cancel the return callback (); // domain requests that url = request.url; var loc = window.location; var hostname = loc.hostname + (loc.port? ":" + Loc.port: ""); if (! / ^ Https ?: \ / \ / ([^ \? \ /] +) /. Test (url) || RegExp. $ 1 === Hostname) Return Callback (); // If not, then post method method = request; method; if (method! == 'GE T ') method =' POST '; // same protocol url = url.replace (/ ^ https ?: /, Loc.protocol); // request! Var xdr = new window.XDomainRequest (); xdr.timeout = Request.timeout; // proxy event var proxy = function (e) {xdr ['at' + e] = function () {request.xhr.dispatchEvent (e);}}} var events = ['progress' 'Timeout', 'error']; var i = 0; i & lt; events.length; ++ i) proxy (events [i]); // Custom Onload xdr.onload = f (action) {callback ({status: 200, status text: "OK", header: {'content-type': xdr.contentType}, text: xdr.responseText})}; Xdr.open (method, url); Xdr.send (request.body); Return});
Comments
Post a Comment