I have an asp.net mvc website that returns a JSON result to certain pages on the website. I would like to be able to also return results to iframes being hosted on other websites. However, if the request is coming from an iframe on another website (I mean from an iframe being hosted on another domain), I would like to be able to detect this in the action of the controller and adjust the results accordingly. Is it possible to know in the action that the request is coming from another domain (or from an iframe, either way)?
Many thanks in advance! I don’t have much experience working across domains…
From another domain yes => simply inspect the
Request.Urlproperty. From an iframe, no, you can’t. There’s nothing defined in the HTTP protocol which enforces requests coming from an iframe to be anyhow different than normal requests.