I have a website where I use Angular for the frontend and Asp.Net Core for the backend. I have an iframe of a different website that I don't own, rendered inside the website. And after a certain amount of time the iframe redirects to the API and sends a POST request to the API. Is there a way to check when the request is completed and perhaps even get the response from the API, so that I can close the iframe or redirect to another page.
Asked
Active
Viewed 229 times
0
-
_"I have an iframe of a different website that I don't own, rendered inside the website"_ - what you're asking might be impossible due to CORS. – Dai Aug 10 '22 at 12:27
-
_"Is there a way to check when the request is completed and perhaps even get the response from the API, so that I can close the iframe or redirect to another page."_ - **potentially** by using this approach: https://stackoverflow.com/questions/14657849/can-i-use-the-browser-navigation-timing-api-for-ajax-events-in-single-page-apps – Dai Aug 10 '22 at 12:30
-
Please provide enough code so others can better understand or reproduce the problem. – Community Aug 11 '22 at 04:40
-
"And after a certain amount of time the iframe redirects to the API and sends a POST request to the API." whether the API is your asp.net core backend api? And whether this post request sent by the website (which you don't own) inside the iframe? If yes, I'm afraid you can't check whether the request is completed of not, because the owner is not you. – Zhi Lv Aug 11 '22 at 06:30
1 Answers
0
When the iframe site makes an API call to your ASP.NET Core backend, send the event to your Angular front-end. Any method of pushing events to a SPA client will work. You could create your own polling process that runs (when the iframe is first opened) or you can setup SignalR and push a server side event to the Angular client using a websocket.
There are some limited ways to communicate between an iframe and its host, but most of those require you to have access to modify the app/site that runs inside of the iframe.

keithwill
- 1,964
- 1
- 17
- 26