gpt4 book ai didi

javascript - 具有冲突值的多个 'X-Frame-Options' header

转载 作者:可可西里 更新时间:2023-11-01 02:52:50 29 4
gpt4 key购买 nike

更新:这适用于 IE,但 Chrome 仍然抛出此错误。我正在尝试用我拥有的另一个网站对我拥有的网站进行 i-frame。这是我在 Chrome 的 JS 控制台中收到的错误消息:

Multiple 'X-Frame-Options' headers with conflicting values ('AllowAll, SAMEORIGIN, AllowAll') encountered when loading 'http://subdomain.mysite.com:8080/Dir/'. Falling back to 'DENY'.
Refused to display 'http://subdomain.mysite.com:8080/Dir/' in a frame because it set 'X-Frame-Options' to 'AllowAll, SAMEORIGIN, AllowAll'.

我到处都搜索了 SAMEORIGIN,我没有在任何地方设置它。

主站点是 www.mysite.com,另一个站点是 subdomain.mysite.com。显然同源政策阻止我这样做。所以我将 subdomain.mysite.com 上的 X-Frame-Options header 设置为“AllowAll”。在开始请求方法中,我添加了这个:

HttpContext.Current.Response.Headers.Remove("X-Frame-Options");
HttpContext.Current.Response.AddHeader("X-Frame-Options", "AllowAll");
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "*");

在页面级别我添加了这个:

<meta name="x-frame-options" content="allowall" />

在 Javascript 中我添加了这个:

<script type="text/javascript">
document.domain = "mysite.com";
</script>

我已经没有什么可以尝试的了……在此先感谢您的帮助。

最佳答案

在我的例子中,添加 header 的是防伪 token 。在 Application_Start 中添加它会阻止它添加它:

AntiForgeryConfig.SuppressXFrameOptionsHeader = true;

然后我添加了 the X-Frame-Options in the web.config因为我需要整个网站都在一个 IFrame 中。

关于javascript - 具有冲突值的多个 'X-Frame-Options' header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22182310/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com