方法一:
在数据服务目录中添加一个Web.config文件,文件内容是:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Methods" value="GET,POST,PUT,DELETE,HEAD,OPTIONS" />
<add name="Access-Control-Allow-Headers" value="Content-Type,api_key,Authorization,X-Requested-With" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>
方法二:
打开IIS,打开数据服务站点,切换到功能视图,点击HTTP响应标头,分别添加:
Access-Control-Allow-Methods : GET,POST,PUT,DELETE,HEAD,OPTIONS
Access-Control-Allow-Origin : *
Access-Control-Allow-Headers : Content-Type,api_key,Authorization,X-Requested-With
时间: 2024-10-10 08:28:18