拒绝显示“在帧中,因为它将'X-Frame-Options'设置为'SAMEORIGIN'

时间:2022-12-13 18:19:08

I've made an MVC ASP.NET C# project which is mainly a form.

我做了一个MVC ASP。NET c#项目,主要是一个表单。

However when I iframe the correct url, it shows up as blank

然而,当我设置正确的url时,它会显示为空

NOTE: i haven't done any line of code regarding iframe

注意:关于iframe,我还没有编写任何代码

Is there an option i need to turn on to make it possible to iframe?

是否有一个选项我需要打开以使它能够进入iframe?

FirefoxConsole Error message:

Load denied by X-Frame-Options: http://localhost:2053/Persons/Create does not permit cross-origin framing.

 Chrome Error message: 

  Refused to display 'http://localhost:2053/Persons/Create' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'. 

1 个解决方案

#1


10  

found the solution: add this to global.asax.cs

找到了解决方案:将它添加到global.asax.cs中

  protected void Application_PreSendRequestHeaders()
    {
        Response.Headers.Remove("X-Frame-Options");
         Response.AddHeader("X-Frame-Options", "AllowAll");

    }

#1


10  

found the solution: add this to global.asax.cs

找到了解决方案:将它添加到global.asax.cs中

  protected void Application_PreSendRequestHeaders()
    {
        Response.Headers.Remove("X-Frame-Options");
         Response.AddHeader("X-Frame-Options", "AllowAll");

    }