asp.net - 在 IFrame 中加载 localhost 站点的问题
问题描述
我有一个要加载到 Iframe 中的 MVC 站点。我已将 X-Frame-Options 添加到 AllowAll。当我尝试加载站点时,我可以在开发人员工具中看到 html 文档,但页面中的 IFrame 是空白的。
我尝试在 localhost 上创建一个具有不同端口号的 Web 应用程序,并且尝试在 Iframe 中加载 MVC 站点,但它没有工作。我试图在同一个 MVC 站点中添加一个 html 并将其自身加载到 html 的 Iframe 中(假设端口问题,但它仍然不会加载)。
任何帮助将不胜感激。
解决方案
我最近遇到了类似的问题。标题X-Frame-Options
对我不起作用。我不得不使用Content-Security-Policy
标题。在web.config
文件中,我将其设置为frame-src https://my-domain.com
:
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Content-Security-Policy" value="frame-src {your domain here}" />
</customHeaders>
</httpProtocol>
</system.webServer>
推荐阅读
- bash - 如何在循环中追加新行\ n
- javascript - 如何防止显示的实际文件路径检查网络终端
- python - 如何检查某些输入是否属于 sympy 函数?
- android - 如何同时从本地电话簿和谷歌联系人中获取所有联系人?
- android - ConstraintLayout that should support portrait and landscape modes -with a button to toggle full screen
- javascript - 如何在不模拟 ActivatedRouteSnapshot 的情况下测试角度防护/解析器
- go - 如何在 Github 上设置我的 Golang 项目版本
- python - 使用 GoogleNews-vectors-negative300.bin 构建字典返回 ValueError: could not convert string to float
- sql - 使用 JSON_MODIFY 更新 JSON
- sql - 如何在 SQL Server where 子句中忽略 ' 字符?