Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - Response object

 
Thread Tools Search this Thread
Old 08-04-2005, 02:31 PM   #1
Default Response object


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
  Reply With Quote
Old 08-04-2005, 04:20 PM   #2
Stefan
 
Posts: n/a
Default Re: Response object
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
  Reply With Quote
Old 08-04-2005, 04:35 PM   #3
masoud bayan
 
Posts: n/a
Default Re: Response object
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
  Reply With Quote
Old 08-09-2005, 11:27 AM   #4
Cactus Corp.
 
Posts: n/a
Default Re: Response object
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.
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

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




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46