0

I had an ASP.Net webpages site working fine (it's a booking application that people link to - a hosted service).

Some people just allowed a link to my site/application to open in a new window. Other embeded it within an IFrame on their site.

I have started updating it to MVC - however, the MVC version no longer works within an IFrame.

Is there any way, within IIS7.5 or within the controllers in MVC, to allow my application/site to display wihin an iFrame?

Thank you,

Mark

Mark
  • 7,778
  • 24
  • 89
  • 147
  • Do you have an example of what it is or isn't doing? Are you getting an error? Off the top of my head I can't think of any reason that the server-side technology (WebForms vs. MVC) should make any difference. – Craig W. Apr 11 '14 at 15:39
  • Is MVC setting an X-Frame-Options response header automatically for you? – Ian Gilroy Apr 11 '14 at 16:12
  • Hi - there is no error - the iframe window is just blank when looking at the MVC version. Also, there is no X-Frame-Options header being set - I checked that too, thanks. – Mark Apr 11 '14 at 16:27
  • @MarkTait how did you solve it? – Rolando Jun 26 '14 at 19:15

2 Answers2

0

Have you tried this? Link below claims if the iframe's source site has the following css, it produces a blank iframe.

html{ position: relative; }

Blank iFrame in IE

I've used iframes inside MVC apps before, so they do work. But, I've only used them within the same domain.

Community
  • 1
  • 1
Dragn1821
  • 807
  • 2
  • 8
  • 19
  • Hi - thanks for the suggestion. This is in Chrome - and different domains, so maybe some sort of inbuilt security feature. – Mark Apr 12 '14 at 11:35
0

It looks like Microsoft.NET updated MVC to automatically write out a SAMEORIGIN X-Frame-Option header that would supersede any attempts you've made to add your own custom headers.

This other Stack Overflow answer gave me the solution:

      After update to MVC 5, iframe no longer works

Also here's a blog post that details more about this issue:

      MVC5 prevents your website being loaded in an IFRAME

Community
  • 1
  • 1
CodingSamurai
  • 101
  • 1
  • 7