发布:2021/9/26 16:44:06作者:管理员 来源:本站 浏览次数:1230
win2008服务器的iis是7.0版,而win2016服务器的iis是10版,所以在IIS配置上有很多变化,不用像在iis7.0下站点web.config文件中配置很多的属性。
比如:
1、MIME类型,在IIS10以前版本都必须自己添加一些类型,比如:.mp4,.mp3,.eot,.otf,.ttf,.woff,.woff2,.svg
IIS10以前版本:
<staticContent>
<mimeMap fileExtension=".mp4" mimeType="application/octet-stream" />
</staticContent>
IIS10版本:
<staticContent>
<!--不再配置常用类型--->
</staticContent>
2、IIS配置允许跨域后,还是无法跨域,请检查<handlers>
win2008下IIS配置:
<system.webServer>
<httpProtocol>
<!--跨域配置开始-->
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<!--支持的http 动作-->
<add name="Access-Control-Allow-Headers" value="AuthToken, Authorization, Origin, Content-Type, Accept, X-Requested-With" />
<!--响应头 请按照自己需求添加 这里新加了token这个headers-->
<add name="Access-Control-Request-Methods" value="GET, POST, PUT, DELETE, OPTIONS" />
<!--允许请求的http 动作-->
</customHeaders>
<!--跨域配置结束-->
</httpProtocol>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0"/>
<remove name="OPTIONSVerbHandler"/>
<remove name="TRACEVerbHandler"/>
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler"
preCondition="integratedMode,runtimeVersionv4.0"/>
</handlers>
</system.webServer>
关键问题是这两行代码
win2016下解决文案:
1、直接删除
<remove name="OPTIONSVerbHandler"/>
<remove name="TRACEVerbHandler"/>
<system.webServer>
<httpProtocol>
<!--跨域配置开始-->
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<!--支持的http 动作-->
<add name="Access-Control-Allow-Headers" value="AuthToken, Authorization, Origin, Content-Type, Accept, X-Requested-With" />
<!--响应头 请按照自己需求添加 这里新加了token这个headers-->
<add name="Access-Control-Request-Methods" value="GET, POST, PUT, DELETE, OPTIONS" />
<!--允许请求的http 动作-->
</customHeaders>
<!--跨域配置结束-->
</httpProtocol>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0"/>
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler"
preCondition="integratedMode,runtimeVersionv4.0"/>
</handlers>
</system.webServer>
2、直接取消 handlers
<system.webServer>
<httpProtocol>
<!--跨域配置开始-->
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<!--支持的http 动作-->
<add name="Access-Control-Allow-Headers" value="AuthToken, Authorization, Origin, Content-Type, Accept, X-Requested-With" />
<!--响应头 请按照自己需求添加 这里新加了token这个headers-->
<add name="Access-Control-Request-Methods" value="GET, POST, PUT, DELETE, OPTIONS" />
<!--允许请求的http 动作-->
</customHeaders>
<!--跨域配置结束-->
</httpProtocol>
<!--
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0"/>
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler"
preCondition="integratedMode,runtimeVersionv4.0"/>
</handlers>
-->
</system.webServer>
© Copyright 2014 - 2024 柏港建站平台 ejk5.com. 渝ICP备16000791号-4