0

I have a form submitted to the server. Server done some processing - then I need to create an iframe (hidden one) have it run for 10s and continue processing code on the server and only then "return" an answer to the web page.

Is there a way to achieve this in asp.net ?

I've tried to add iframe code into existing div but of-course it will not happen until I return my code, but once I'll return the code - I won't be able to continue in the server "after" 10 seconds.

Dani
  • 13,366
  • 11
  • 56
  • 99
  • That's just not how server-side coding works. If you need to make a request from the server, make the request from the server (`HttpWebRequest` is a class for this in .NET Framework, `HttpClient` in .NET Core), wait for it to complete, then continue on your way. – Heretic Monkey Aug 02 '19 at 15:43

1 Answers1

0

You've assumed you need an iframe in order to execute your desired code, but the basis for this assumption isn't obvious from your description (especially the desire for a hidden one, since the point of an iframe is normally to display things to the user). It sounds like an odd requirement and scenario.

The precise flow of request/response and processing isn't entirely clear in your question either, but since you seem to be concerned about this 10 second delay it sounds to me like this feature might be something which ought to be implemented via AJAX, or even WebSockets. These technologies are the normal way to allow you to send and receive data between browser and server, execute code on the server, without the user having to wait for a page refresh.

ADyson
  • 44,946
  • 12
  • 41
  • 55
  • This is a requirement from a credit card processor. they want to render a hidden iframe on the client web browser posting some data to that iframe, and after 10 seconds continue processing the original request.... – Dani Aug 02 '19 at 16:28
  • Ok well sounds like you could potentially use Ajax to do your initial request to your server, then when that returns, render the iFrame, then after 10 seconds post back your page or do another Ajax to your server to continue your own processing – ADyson Aug 02 '19 at 16:58
  • Not sure what "posting data to that frame" means though. You can't post data to a frame...only to a URL at a server. Have these people given you any proper instructions? – ADyson Aug 02 '19 at 16:59
  • here are the exact instructions: Render a hidden HTML iframe in the Cardholder’s browser and send a form with a field named "xxxx" containing the Base64url JSON Object via HTTP POST. – Dani Aug 02 '19 at 19:41
  • 1
    Ok...sounds like they are referring to this concept: https://stackoverflow.com/questions/168455/how-do-you-post-to-an-iframe – ADyson Aug 02 '19 at 22:54