【发布时间】:2014-07-06 12:10:17
【问题描述】:
我收到以下错误:
XMLHttpRequest cannot load http://localhost:62574/ServiceClass.asmx?op=loadMarkersViaWebService. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:15540' is therefore not allowed access.
所以我在 Web.Config 中添加了以下内容,但是错误仍然存在:
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true"/>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="http://localhost:15540/"/>
</customHeaders>
</httpProtocol>
【问题讨论】:
-
我看到端口不匹配?
-
@Niels 否,应用程序使用 15540,而 Web 服务使用 62574
-
在这里查看我接受的答案:stackoverflow.com/questions/22127442/…
-
@rikket ,找到解决方案了吗?我有同样的问题。
标签: c# javascript web-services cors