我们的网站目前无法免遭点击劫持,因此我进入了web.config并添加了
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="X-Frame-Options" value="DENY" />
</customHeaders>
</httpProtocol>
</system.webServer>
Run Code Online (Sandbox Code Playgroud)
这是非常简单的代码.我的问题是它不起作用.我的问题是:
X-Frame-Options在标题响应中?我用httpfox查找它并没有得到任何东西,所以我无法验证它web.config是否真的把东西放在标题中.我确实尝试将它添加到方法中的Global.asax中Application_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)