未在响应中返回Web.config customHeaders [英] Web.config customHeaders not returned in a response

查看:84
本文介绍了未在响应中返回Web.config customHeaders的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在web.config的system.webServer/httpProtocol/customHeaders部分中有一些自定义标头,它们是在实时服务器的响应中正确返回的.

I have some custom headers in system.webServer/httpProtocol/customHeaders section in web.config and they are properly returned in a response from live servers.

最近,我们在具有相同IIS/.NET配置的其他服务器上安装了相同的应用程序,由于某些原因,这些web.config定义的标头将被忽略,并且不会作为响应返回.

Recently we installed the same app on a different server with same IIS/.NET configuration and for some reason these web.config defined headers are ignored and not returned in response.

有什么主意吗?

推荐答案

最后我找到了问题.我在%WINDIR%\ System32 \ inetsrv \ config \ applicationHost.config 中的配置中添加了位置元素,并添加了所需的标头,并且标头开始出现在响应中

Finally I found the problem. I added location element to the config in %WINDIR%\System32\inetsrv\config\applicationHost.config with the headers I needed and headers start appearing in the response

<configuration>
...
<location path="MyWebsite">  
    <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,PUT,POST,DELETE,HEAD,OPTIONS" />
            <add name="Access-Control-Expose-Headers" value="*" />
            <add name="Access-Control-Request-Headers" value="*" />
            <add name="Access-Control-Request-Method" value="GET,PUT,POST,DELETE,HEAD,OPTIONS" />
            <add name="X-Frame-Options" value="DENY" />
          </customHeaders>
        </httpProtocol>
    </system.webServer>  
</location>
...
</configuration>

这篇关于未在响应中返回Web.config customHeaders的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆