【问题标题】:Issue with loading localhost site in IFrame在 IFrame 中加载 localhost 站点的问题
【发布时间】:2020-01-15 05:23:29
【问题描述】:

我有一个要加载到 Iframe 的 MVC 网站。我已将 X-Frame-Options 添加到 AllowAll。当我尝试加载站点时,我可以在开发者工具中看到 html 文档,但页面中的 IFrame 是空白的。

我尝试在 localhost 上创建一个具有不同端口号的 Web 应用程序,并且我尝试在 Iframe 中加载 MVC 站点,但没有成功。 我尝试在同一个 MVC 站点中添加一个 html 并将其自身加载到 html 的 Iframe 中(假设存在端口问题,但仍然不会加载)。

我们将不胜感激。

【问题讨论】:

    标签: asp.net iframe


    【解决方案1】:

    我最近遇到了类似的问题。 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>
    

    【讨论】:

    • 我这样做了,但仍然没有运气:localhost:50569" />
    • 我从未尝试过 localhost,但如果将 Content-Security-Policy 设置为 value="frame-src 'self'" 或尝试不使用端口号,它可能会起作用:value="frame-src localhost"
    猜你喜欢
    • 1970-01-01
    • 2021-01-13
    • 1970-01-01
    • 2015-05-16
    • 1970-01-01
    • 2011-06-14
    • 1970-01-01
    • 1970-01-01
    • 2011-11-23
    相关资源
    最近更新 更多