首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >内容安全策略框架-在IE 11中不起作用的祖先

内容安全策略框架-在IE 11中不起作用的祖先
EN

Stack Overflow用户
提问于 2019-05-04 00:46:18
回答 1查看 3.1K关注 0票数 1

这样做的目的是阻止其他网站在iframe中显示我们网站的内容。

我不能使用X-Frame-Options = SAMEORIGIN,因为网站的网址。主节点为www.xyz.com,子节点为sec.xyz.com。

所以我求助于内容安全策略(...表示其他域等)

代码语言:javascript
复制
<httpProtocol>
            <customHeaders>
                <add name="Content-Security-Policy" value="default-src 'self' localhost ...; script-src 'unsafe-inline' 'unsafe-eval' *;               style-src 'unsafe-inline' *; img-src * data; font-src * data:;               frame-ancestors 'self' localhost ...;" />
            </customHeaders>
        </httpProtocol>

FF和Chrome不会在测试页面iframe中显示站点。

现在IE 11在iframe中显示了站点,因为不支持frame-祖先。https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors

我尝试在全局文件中添加头文件X-Content-Security-Policy,但IE11仍然显示该站点。

代码语言:javascript
复制
protected void Application_BeginRequest(object sender, EventArgs e)
    {
        HttpContext.Current.Response.AddHeader("X-Content-Security-Policy", "frame-ancestors 'self' localhost ...");
    }

如何使IE 11遵守标头X-Content-Security-Policy

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-05-10 03:00:42

IE不支持X-Content-Security-Policyframe-ancestors。使用X-Frame-OptionsALLOW-FROM定位IE。

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55974092

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档