![]() |
|
|
|
#1 |
|
Hi,
I am developing an asp.net page that iteratively (inside a loop) calls a web service at the backend and shows the result to user. For this purpose I should update page with the web service response after each call to show a progress to user. I used following code to test, but it does not work and after user clicks on start button, page will not be refreshed with each Response.Flush() call, and only after finishing the loop all information will be shown together: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Response.Buffer = True Response.BufferOutput = True Response.CacheControl = "no-cache" Response.AddHeader("Pragma", "no-cache") End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click For i As Integer = 1 To 3 Response.Write(11111111111111 * i) Response.Write("<br>") Response.Flush() System.Threading.Thread.Sleep(2000) Next End Sub I am wondering why the response output is not being sent to browser until the page processing is done. One interesting thing is, after first hitting of start button when I press browser's F5 button (refresh) ,browser shows page response line by line as it is supposed to work but again when I hit start button it shows response all together. It could be browser caching problem so I added two lines of the above code to disable cache but still have this problem. Any advice is appreciated. Thanks Masoud masoud bayan |
|
|
|
|
#2 |
|
Posts: n/a
|
I don't understand how the approach could work.
I would think a browser refresh (meta http-equiv="refresh" content="2;url=yoursite.com"/) would work for what you describe (besides it does not hold your worker thread hostage for 6 seconds). Or, if you want to do it more fancy use remote scripting aeh ajax - it is well suited for stuff like progress bars. Also, if you do not actually have to display any response data from your ws calls, then you could simply do a javascript progress bar, which runs for 6 seconds (giving the user the calming feeling of progress happening) and then simply refresh (using a js timer). Stefan |
|
|
|
#3 |
|
Posts: n/a
|
Thanks for your comment.
Think we have a loop, counting from 1 to 10 in the code behind and inside that loop we have a sleep of two or three seconds for each loop count. Then we want to show to user, progress of counter numbers as: 1 after 2 second : 1 2 after 2 second: 1 2 3 .... can you show me an example (or a link) that how we can imlement it with your suggestion? "Stefan" <> wrote in message news: oups.com... > I don't understand how the approach could work. > > I would think a browser refresh (meta http-equiv="refresh" > content="2;url=yoursite.com"/) would work for what you describe > (besides it does not hold your worker thread hostage for 6 seconds). > Or, if you want to do it more fancy use remote scripting aeh ajax - it > is well suited for stuff like progress bars. > > Also, if you do not actually have to display any response data from > your ws calls, then you could simply do a javascript progress bar, > which runs for 6 seconds (giving the user the calming feeling of > progress happening) and then simply refresh (using a js timer). > masoud bayan |
|
|
|
#4 |
|
Posts: n/a
|
Hi there
The renderer usually waits for end of response before sending it to the client. This relates to the 'response buffer' feature. You need to disable the response buffer at the beginning of the page : Response.Buffer = false; This will make the server start sending output information to the client before the end of the page is rendered. For example try this: -------------buffer.aspx ------------- Response.BufferOutput = false; for(int i=0;i<10;i++) { Thread.Sleep(500); Response.Write(i+"<br/>"); Response.Flush(); } ------------------------------------- This will work on Firefox. There must be some client side setting in IE which prevents displaying the page before its content is completely returned... Antonio Cactus Corp. |
|
![]() |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Different Ping response times | sandhyashyamsundar | Hardware | 1 | 07-07-2009 06:22 PM |
| COM object in asp.net | fluoronator | Software | 1 | 03-04-2008 07:48 PM |
| create js object | meera_p9 | Software | 0 | 10-19-2007 07:09 AM |
| Active X cannot create this object | gellison | General Help Related Topics | 0 | 08-09-2007 06:42 PM |
| Re: RIAA/MPAA 'impressed' with their brothers proportionate response in Lebenon/Palestine | john339077353@cs.com | DVD Video | 0 | 08-04-2006 10:23 PM |