0
默认情况下,我的网站具有x-frame-options:启用SAMEORIGIN标头。我想从特定的视图中删除它,以允许该视图托管在第三方iFrame中。MVC5:如何覆盖或更改特定视图的标题?
public ActionResult Callback1()
{
// Remove the anti-clickjacking setting
Response.Headers.Remove("X-Frame-Options");
Return View();
}
// Does not remove the header
public ActionResult Callback2()
{
// Try to override the setting
Response.Headers["X-Frame-Options"] = "ALLOW-FROM https://foo.com"
Return View();
}
// Results in x-frame-options: ALLOW-FROM https://foo.com, SAMEORIGIN
任何帮助,将不胜感激。
谢谢。我接受了你的答案,但我翻转了这个解决方案并创建了2个过滤器。一个我在整个网站上启用SAMEORIGIN保护,另一个在必要时删除它。这样,如果我忘记将它应用到某个地方,我不会离开该网站。 –
这似乎并没有做任何我已经发送页面/刷新和重定向,但没有写入页面,它不会重定向 – djack109