小编Moi*_*awk的帖子

X-Frame-Options无法运行IIS web.config

我们的网站目前无法免遭点击劫持,因此我进入了web.config并添加了

<system.webServer>
    <httpProtocol>
        <customHeaders>
            <add name="X-Frame-Options" value="DENY" />
        </customHeaders>
    </httpProtocol>
</system.webServer>
Run Code Online (Sandbox Code Playgroud)

这是非常简单的代码.我的问题是它不起作用.我的问题是:

  1. 有没有办法让我看看是否X-Frame-Options在标题响应中?我用httpfox查找它并没有得到任何东西,所以我无法验证它web.config是否真的把东西放在标题中.
  2. 为什么这不起作用?我可以做些什么来测试或前进?

我确实尝试将它添加到方法中的Global.asaxApplication_Start,但是当我调试时,我似乎无法"击中"此方法; 它没有达到断点.

private void Application_Start(object sender, EventArgs e)
{
    // Code that runs on application startup
    HttpContext.Current.Response.AddHeader("x-frame-options", "DENY");

    LogHelper.Info("Cost of Care Web Application Starting");
}
Run Code Online (Sandbox Code Playgroud)

我想补充一点,我已经尝试将其直接添加到head标签中,我也尝试将其添加到元标记中,如此

<meta http-equiv="X-Frame-Options" content="deny">
Run Code Online (Sandbox Code Playgroud)

iis x-frame-options

18
推荐指数
5
解决办法
6万
查看次数

标签 统计

iis ×1

x-frame-options ×1