【发布时间】:2014-05-06 13:06:06
【问题描述】:
我创建了一个 WCF 数据服务并在我的网页中设置了以下内容:
var mongo = new MyCtx.MyContext({ name: 'oData', oDataServiceHost: 'http://xxxxxxxxx/MongoDataService.svc/', enableJSONP: false });
在我的 WCF 数据服务 web.config 中:
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Max-Age" value="3600" />
<add name="Access-Control-Allow-Headers" value="Origin, X-Requested-With, Content-Type, Accept, MaxDataServiceVersion" />
<add name="Access-Control-Allow-Methods" value="PUT, POST, GET, DELETE, MERGE, OPTIONS" />
</customHeaders>
</httpProtocol>
当我尝试打开它时,我收到以下错误:
SEC7118: http://xxxxxxxxxxxxxx/MongoDataService.svc//DataTable1 " XMLHttpRequest for [URL] required Cross Origin Resource Sharing(CORS).
SEC7119: "XMLHttpRequest for [URL] required CORS preflight."
SCRIPT7002: XMLHttpRequest: Network problem 0x80070005, Access denied.
我的 IIS 服务器定义了以下标头:
我还应该做什么?
【问题讨论】:
-
就我而言,我只添加了
并且它可以工作。也许您应该尝试删除其他人? -
@QianLi 我修改了它,但没有任何反应。它仍然希望启用 CORS。我可以完全访问 IIS 服务器,但无法启用这么小的东西...
标签: jquery cors wcf-data-services jaydata