0

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

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

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

Is there an option i need to turn on to make it possible to 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'. 
SNT
  • 293
  • 1
  • 2
  • 13

1 Answers1

18

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

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

    }
SNT
  • 293
  • 1
  • 2
  • 13
  • 1
    My situation: I made a application in ASP.NET MVC 5 and then try to render on a iframe in Sharepoint site, i got the error that says in the tittle of this post, and with your answer everything works fine. I want to know where did you find this answer? just to future documentation. – mejiamanuel57 Apr 18 '16 at 17:44
  • Is "AllowAll" value a part of any specification? If is not mentioned here: https://tools.ietf.org/html/rfc7034 – C-F Jan 30 '18 at 01:01