MVC 5 prevents通过Iframe广告对内容的访问 [英] MVC 5 prevents access to content via Iframe

查看:181
本文介绍了MVC 5 prevents通过Iframe广告对内容的访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自从从MVC4升级到MVC5,我已经注意到添加到我的网页额外服务器头:

Ever since the upgrade from MVC4 to MVC5, I have noticed an extra server header added to my web pages:

X框选项:SAMEORIGIN

X-Frame-Options: SAMEORIGIN

据我了解添加此标签的安全优势,但页面之一,就是要包括来自其他项目的iframe(在其他域)里面,这额外的头部是preventing这一点。

I understand security benefits of adding this tag, but one of the pages is meant to be included inside an iframe from other projects (on other domains), this extra header is preventing this.

我已经验证它不是,它是将标题中的托管服务器IIS7,当我降级到MVC4 - 头走了。

I have verified it is not the hosting IIS7 server that is adding the header, and when I downgraded back to MVC4 - the header is gone.

有谁知道如何从MVC5删除此默认?

Does anyone know how to remove this default from MVC5?

推荐答案

MVC5自动添加HTTP标头X框,选择与 SAMEORIGIN 。这$ P $被加载到pvents您的网站 IFRAME

MVC5 automatically adds the HTTP header X-Frame-Options with SAMEORIGIN. This prevents your site from being loaded into an iframe.

但是,我们可以在的Application_Start 在关闭此功能的的Global.asax.cs

But we can turn this off in Application_Start in the Global.asax.cs.

示例

protected void Application_Start()
{
    AntiForgeryConfig.SuppressXFrameOptionsHeader = true;
}

更新

我已经写了这个的 MVC5 prevents您的网站在IFRAME 装载

这篇关于MVC 5 prevents通过Iframe广告对内容的访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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