0

I am trying to embed an entire azure website into a wordpress site. The following works:

 <iframe src="https://tvirusly.azurewebsites.net" height="1200" width="1600" title="Covid Risk Calculator"></iframe>

but when I click inside the above website or use the following script, it does NOT work:

<iframe src="https://tvirusly.azurewebsites.net/AnonymousEvents/Create" height="1200" width="1600" title="Covid Risk Calculator"></iframe>

I get the error that tvirusly.azurewebsites.net refused to connect.

Thank you in advance for your help.

sidsud
  • 25
  • 9

1 Answers1

0

This happens because the URL https://tvirusly.azurewebsites.net/AnonymousEvents/Create sends the X-Frame-Options: SAMEORIGIN header. It prevents the site to be included in an iFrame.

If you have access to the source code of tvirusly.azurewebsites.net, then you can see this solution: Windows Azure iframe domain provider = issue with X-Frame-Options.

You basically set X-FRAME-OPTIONS to an empty string.

If you can't change the source, then you're out of luck.

Roman K.
  • 945
  • 1
  • 9
  • 17
  • Thanks Roman for that link. That particular solution assumes an App.cs. How would I do this for an MVC ASP.NET azure website where there is no App object? Thanks. – sidsud Apr 13 '21 at 13:19
  • 1
    This was [already answered](https://stackoverflow.com/questions/20253840/after-update-to-mvc-5-iframe-no-longer-works). Open Global.asax and add `System.Web.Helpers.AntiForgeryConfig.SuppressXFrameOptionsHeader = true; ` in `Application_Start()`. – Roman K. Apr 13 '21 at 15:00
  • I don't have a global.asax in my project. it is an ASP.NET MVC project – sidsud Apr 13 '21 at 16:57
  • 1
    Then you are using ASP.NET Core. Global.asax is replaced by Startup.cs in Core. Maybe this will help https://stackoverflow.com/questions/40523565/asp-net-core-x-frame-options-strange-behavior. – Roman K. Apr 13 '21 at 17:57