我試圖加載谷歌使用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錯誤。