Frank
Frank

Reputation: 7585

Web application tell request from iframe?

In asp.net, is there any way to tell if a request is from "iframe"??

Thank you very much

Upvotes: 1

Views: 834

Answers (2)

Ashlee Saunders
Ashlee Saunders

Reputation: 11

Here is the answer from javascript

var isIframe = (window.location != window.parent.location) ? true : false;

Then you can use some Ajax request, or maybe enable pageMethods and send that information server-side.

Upvotes: 1

Erik Nedwidek
Erik Nedwidek

Reputation: 6184

Not if you do not have control over the request. If someone creates an a page with an iFrame and then loads your content in it, there will be no difference in the request.

If you are making the request, then you can add a query string parameter such as ?fromIFrame=1 and tell your asp.net application that it is coming from an iFrame.

Upvotes: 3

Related Questions