Question Bottleneck after button click

Comotose

Member
Joined
Mar 8, 2010
Messages
23
Programming Experience
1-3
Hi all.

I seem to have some sort of a bottleneck problem with a webpage that contains the following sub:
VB.NET:
31 Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
32	        
33	' Hide the button from further clicking.
34	Button1.Visible = False
35
36	' Create the target URL complete with QueryString.
37	Dim target As String = "next-page.aspx?" & qstring.ToString()
38
39	' Message to display after button click.
40	lblPleaseWait.Text = "Operation in progress. Please wait until it completes... "
41
42	' Move on to the next page.
43	Response.Redirect(target)
44
45 End Sub
There's a fair bit of data sent to the next (target) page at Line 43, and the target page can take a while to process everything.

There's no visible content on the target page, it's all processing in a .aspx.vb file.

The problem...

is that the current page (the one with the above Sub on it) stays visible the whole time while the processing is done by the target page, and the next page only displays after the processing is all completed.

I wasn't expecting that, but I can live with it, *IF* I could hide the button and present the "please wait" message.

But as things stand at the moment, once the button is clicked control is handed to the .aspx.vb target file and nothing else happens until processing is complete.

I don't understand why the preceding actions, lines 34 and 40, aren't allowed to complete before the redirection takes control.
 
I don't understand why the preceding actions, lines 34 and 40, aren't allowed to complete before the redirection takes control.
ASP.NET Page Life Cycle Overview The loading of a page is not a interactive process between client and server, what happens is this (a) client sends request to server, (b) server processes the request, (c) result is sent from server to client, (d) client displays the result. You server-side code belongs to the (b) part.

One simple approach could be to have an intermittent "please wait" page that again calls the page that takes a while.

Depending on circumstances it may be a possible for you to implement some kind of asynchronous processing in your server application, possibly in a AJAX context, but this is something you have to do more research on.
 
Thanks John.

I was hoping to avoid the interim page but it looks like that might have to be the route to take. I'm afraid the "asynchronous processing in your server application" suggestion is a bit beyond me at this stage -- I'm just starting out with ASP.NET.

Everything works fine if I just comment out the Response.Redirect line, so I was hoping there was some way to force completion of all previous actions before getting to the page redirection.
 
I had previously tried to work with Flush but without success.

In the end the only way I have managed to get it to work is by using an interim page to tell the user what's happening, which in turn calls the problem page using a meta refresh:

<META http-equiv="refresh" content="0;URL=<%=target%>">

The interim page displays some information and an animated activity GIF until the problem page has finished processing, then everything is back to normal.

Not exactly pretty, but at least it works.
 
Back
Top