ASP.NET - Display messages on Page_Load - Asked By SP on 16-Oct-14 01:13 PM

I have an issue with one page in asp.net web application. There are several steps which are being performed on the page_load event of this page and once everything is done, it redirects to another page with post information.


My question is I want to show/display messages once each step is completed on the page. All the code is on Page_Load event.

I want to show like,

- Creating an API call URL...
- API called...
- Token Generated...
- Redirect URL created...
- Redirecting to client URL ...

I tried using, Thread.Sleep and System.Diagnostics.Trace.WriteLine, but didn't get success.

Robbe Morris replied to SP on 16-Oct-14 01:20 PM
You won't be able to accomplish this sort of thing using the tactics you've outlined here.  The web is a disconnected environment between the client and the server.  You won't be able to intermittently send messages back the client from server side code "during" a postback like this.

If you absolutely "needed" this, you'd have to wire up a bunch of code to trigger this process async or on a different thread with some sort of tracking indicator for each step and let the postback fully complete prior to all of these steps completing.  To display the current step, you'd have to make JavaScript calls back to the server (after page_load of the postback) and display the response.  You could do your tracking in session or database.
SP replied to Robbe Morris on 16-Oct-14 03:23 PM
Can I do something in Visual Studio console? I have tried it yet and don't know how to use it?

Please let me know if some example is there. I need to show at least some way during the process. 
Robbe Morris replied to SP on 16-Oct-14 03:23 PM
A console app is not for use in an ASP.NET app.  That won't help you.