我试图加载谷歌使用MVC5映射到的iframe但我正在逐渐被堵塞,错误允许从不同域帧与MVC5
拒绝在一个框架中显示“https://www.google.com/maps?cid=XXXXX”,因为它设置“X -Frame-Options“改为”SAMEORIGIN“。
所以经过一番搜索,我已经试过如下:
在global.ascx
创建属性添加
AntiForgeryConfig.SuppressXFrameOptionsHeader = true;
到Application_Start
(已经有和没有设置试过这种在global.ascx中):public override void OnActionExecuted(ActionExecutedContext filterContext) { if (filterContext != null) { filterContext.HttpContext.Response.Headers["X-Frame-Options"] = "ALLOW-FROM https://www.google.com"; base.OnActionExecuted(filterContext); } }
tryi纳克属性
OnResultExecuted(ResultExecutedContext filterContext)
而不是OnActionExecuted
删除它在web.config中:
<httpProtocol> <customHeaders> <remove name="X-Frame-Options" /> </customHeaders> </httpProtocol>
有我丢失的东西?我该如何摆脱这个http头(或者至少改变它来允许地图)?
更新
我刚才检查所发送的头,他们是在正确的,他们要么说
X框-选项:允许-FROM https://www.google.com
或者根本没有,如果我删除的属性,但保持global.ascx更新
但是,当我运行该页面并查看这些标题时,它仍然给我SAMEORIGIN错误。