Access-Control-Allow-Origin'标头存在于请求的资源上

CORS No 'Access-Control-Allow-Origin' header is present on the requested resource

本文关键字:请求 资源 于请求 存在 Access-Control-Allow-Origin      更新时间:2023-09-26

我得到以下错误:

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中添加了以下内容。

<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true"/>
<httpProtocol>
  <customHeaders>
    <add name="Access-Control-Allow-Origin" value="http://localhost:15540/"/>
  </customHeaders>
</httpProtocol>

尝试使用这个…

<httpProtocol>
 <customHeaders>
   <add name="Access-Control-Allow-Origin" value="*" />
   <add name="Access-Control-Allow-Headers" value="Content-Type, Accept" />
 </customHeaders>
</httpProtocol>
相关文章: