user1110648
user1110648

Reputation:

iframe not loading content in ASP.NET application

I have a small snippet of code that I want to load a portion of another website embedded in one of my aspx pages:

<tr>
   <td style="padding-left:15px;">
      <iframe src="http://www.google.com/" width="210" height="100" /></iframe>
   </td>
</tr>

When I view the page in IE the frame has the following warning text:

To help protect the security of information you enter into this website, the publisher of this content does not allow it to be displayed in a frame.

However, under no circumstances does google.com, or any other external page load for that matter. An iframe is a pretty simple tag...is something obvious missing, or is ASP.NET imposing some contraint?

Thanks in advance.

Upvotes: 2

Views: 7826

Answers (4)

x0n
x0n

Reputation: 52480

Read the warning text - it is telling the truth. The publisher (google) does not permit hosting their site in an iframe or frame. Google does this by adding a http header, "X-FRAME-OPTIONS: DENY" which modern browsers will - and should - obey.

https://developer.mozilla.org/en/The_X-FRAME-OPTIONS_response_header

Upvotes: 2

RickNZ
RickNZ

Reputation: 18652

If you're trying to load a page from your own site in an iframe, and if you're using ASP.NET sessions, it's possible to encounter a race condition that will prevent that iframe from loading.

For third-party sites, though, as others have said, ASP.NET doesn't care; "it's a browser thing".

Upvotes: 0

ChrisLively
ChrisLively

Reputation: 88092

Numerous websites actively prevent you from loading their content in a frame. Even StackOverflow denies this.

Some actively take control of the browser and force the top level to redirect to their homepage. There are a lot of reasons for doing this.

So, if you want to put your own content in an iFrame, that's fine. However, if you want to put other people's content in an iFrame then I'd suggest that you stop. It isn't considered polite behavior anymore.

Upvotes: 0

ASetty
ASetty

Reputation: 114

No this this nothing to do with ASP.NET it is all client side issue. I just created a plain HTML page and got same error in IE but works well in FireFox

   <htmL>
   Test page
   <table>
   <tr>
     <td style="padding-left:15px;">
       <iframe src="http://www.google.com/" width="210" height="100" /></iframe>
    </td>
  </tr>
  </table>
  </htmL>

Upvotes: 0

Related Questions