After update to MVC 5, iframe no longer works

后端 未结 2 579
深忆病人
深忆病人 2020-12-09 18:12

I updated my project MVC version to 5 and now iFrame does not load, I get this error:

Load denied by X-Frame-Options: www.blahblah.com does not permit cross

相关标签:
2条回答
  • 2020-12-09 18:56

    Assuming your IFrame content is being served by your MVC app...

    You might need to include a response header that permits cross origin requests:

    Access-Control-Allow-Origin: *

    0 讨论(0)
  • 2020-12-09 19:15

    I finally found the answer. Starting with MVC 5 Microsoft decided to set SAMEORIGIN in there by default. The best way I found to turn this tag off is by writing the following in the Global.asax.cs

    protected void Application_Start()
    {
    //Bundles and stuff are here
    AntiForgeryConfig.SuppressXFrameOptionsHeader = true;
    }
    
    0 讨论(0)
提交回复
热议问题