asp.net - 在 MVC3 或 IIS 7.5 中禁用 x-frame-options

标签 asp.net iis iframe web-config x-frame-options

我想在我的网站中禁用 x-frame-options,我希望没有其他网站可以使用 iframe 在他们的网页中显示我的网页。我的网站是在 ASP.net MVC3 中制作的,并托管在 IIS 7.5 中。

最佳答案

有很多方法可以解决这个问题。但最简单的方法之一是添加 <customHeaders>部分添加到 web.config 并将该 header 附加到每个请求。

<configuration>
   <system.webServer>
      <httpProtocol>
         <customHeaders>
            <add name="X-Frame-Options" value="DENY" />
         </customHeaders>
      </httpProtocol>
   </system.webServer>
</configuration>

关于asp.net - 在 MVC3 或 IIS 7.5 中禁用 x-frame-options,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23085306/

相关文章:

jquery - 将页面发布到 iframe 会导致弹出窗口阻止程序阻止发布操作

javascript - jQuery 一起从多个选择中获取值

ASP.NET MVC - 我需要呈现部分的操作方法。我该怎么做?

iis - 如何在 Windows 10 预览版中安装应用程序请求路由 ARR 3.0?

iis - DNN : The Web Application Project xxx is configured to use IIS. 找不到 Web 服务器 "http://dnndev/desktopmodules/xxx/'。”

javascript - 不确定网站是否被 iframe 入侵

javascript - ASP.NET Javascript 日期时间时区问题

c# - 在 ASP.NET 中的异步 ajax 事件上执行一行 javascript

asp.net - 在 Azure 应用程序网关卸载时如何需要 SSL?

javascript - 在 iFrame 中打开 CSS 文件时阻止浏览器提示文件下载?