OPTIONS http://localhost:7514/Employees/testrestricted 401 (Unauthorized) angular.js:10419
OPTIONS http://localhost:7514/Employees/testrestricted Origin http://localhost:4064 is not allowed by Access-Control-Allow-Origin. angular.js:10419
XMLHttpRequest cannot load http://localhost:7514/Employees/testrestricted. Origin http://localhost:4064 is not allowed by Access-Control-Allow-Origin.
我已经有这样的 app.js 设置:
var app = angular.module('angular-auth-demo', ['http-auth-interceptor']);
app.config(['$routeProvider', '$httpProvider', function ($routeProvider, $httpProvider) {
$httpProvider.defaults.useXDomain = true;
delete $httpProvider.defaults.headers.common['X-Requested-With'];
$routeProvider.
when('/home', { templateUrl: 'partial-content.html', controller: 'ContentController' }).
otherwise({ redirectTo: '/home' });
}]);
有没有办法找出这是否是 angular 或 asp.net mvc 上的错误,因为我在那端也有一个 cors 配置,但我认为浏览器实际上没有机会访问服务器?