原产地不被访问控制允许来源的angularjs和asp.net mvc的允许 [英] Origin is not allowed by Access-Control-Allow-Origin in angularjs and asp.net mvc

查看:144
本文介绍了原产地不被访问控制允许来源的angularjs和asp.net mvc的允许的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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设置这样既:

I have my app.js setup like this already:

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' });
}]);

有没有办法找出如果这是对角或asp.net的MVC一个错误,因为我对这一目标的CORS配置太多,但我不认为浏览器实际上是得到一个机会击中服务器?

is there a way to find out if this is an error on angular or asp.net mvc, because I have a cors configuration on that end too, but i don't think the browser is actually getting a chance to hit the server?

推荐答案

请求越来越到服务器,因为服务器返回401在Chrome中看到开发工具或Firebug的网络选项卡。假设你有访问控制允许来源头已经,你可能需要指定接入控制允许标题头,并添加内容类型作为它的值。也许发表您的CORS的config / code?

The request is getting to the server because the server is returning a 401. See the network tab in Chrome dev tools or Firebug. Assuming you have the Access-Control-Allow-Origin header already, you probably need to specify the Access-Control-Allow-Headers header and add Content-Type as its value. Maybe post your CORS config/code?

这篇关于原产地不被访问控制允许来源的angularjs和asp.net mvc的允许的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆