访问控制 - 允许一个用户的原始错误 [英] Access-Control-Allow-Origin error for one user

查看:273
本文介绍了访问控制 - 允许一个用户的原始错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个WCF服务托管在同一个服务器上作为另一个网络应用程序,但在不同的端口。 Web应用程序使用jQuery在WCF服务上执行get / post请求,并且在配置WCF服务以允许跨源请求之后,它可以正常工作和正常工作。

I have a WCF service hosted on the same server as another web app, but on a different port. The web app uses jQuery to perform get/post requests on the WCF service, and after configuring the WCF service to allow cross origin requests it works fine and as expected.

问题有一个问题,有时(不总是),请求不工作,看看Chrome开发控制台WCF服务抛出以下:g

One issue is having an issue where sometimes (not always), the requests don't work and after looking at the Chrome dev console the WCF service is throwing the below:g


XMLHttpRequest无法加载{url}。在所请求的资源上没有Access-Control-Allow-Origin头。因此,不允许原始{origin}访问。该响应的HTTP状态代码为403.

XMLHttpRequest cannot load {url}. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '{origin}' is therefore not allowed access. The response had HTTP status code 403.

我无法复制此内容,他正在使用Google Chrome 。

I can't replicate this at all, and he's using Google Chrome just like other users are. Could it be his machine?

推荐答案

您必须在服务器端添加头像

you have to add headers at server side like

Access-Control-Allow-Origin: *

选中此链接: http:// security。 stackexchange.com/questions/43639/why-is-the-access-control-allow-origin-header-necessary

这篇关于访问控制 - 允许一个用户的原始错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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