您的位置:首页 > 运维架构 > 网站架构

让IIS静态网站支持跨域请求

2017-02-09 17:03 441 查看
在静态网站的web.config中配置customHeaders节点,详情如下
<?xml version="1.0" encoding="utf-8"?>

<!--
有关如何配置 ASP.NET 应用程序的详细信息,请访问 http://go.microsoft.com/fwlink/?LinkId=169433 -->

<configuration>
<system.web>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Headers" value="Content-Type" />
<add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" />
</customHeaders>
</httpProtocol>
<staticContent>
<remove fileExtension=".json" />
<mimeMap fileExtension=".json" mimeType="application/json" />
<remove fileExtension=".mp3" />
<mimeMap fileExtension=".mp3" mimeType="audio/x-mpeg" />
<remove fileExtension=".appcache" />
<mimeMap fileExtension=".appcache" mimeType="text/cache-manifest" />
</staticContent>
<directoryBrowse enabled="true" />
</system.webServer>
<location path="site.appcache">
<system.webServer>
<caching>
<profiles>
<add extension=".appcache" policy="DontCache" kernelCachePolicy="DontCache" />
</profiles>
</caching>
</system.webServer>
</location>
</configuration>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  IIS
相关文章推荐