473,320 Members | 1,854 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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




Nov 19 '05 #1
3 2011
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).

Nov 19 '05 #2
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" <Cl*********@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr 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).

Nov 19 '05 #3
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
Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Stephen | last post by:
I was wondering if someone can help me with an web application design problem. I have a aspx page which builds up an arraylist called addresses and outputs the values in the arraylist items to a...
35
by: Eitan | last post by:
Hello, How can I write a line (with carriage return + line feed) to the client ? response.write("abcd"), continue the last line, and doesn't put cr+lf. response.writeLn is illegal syntax... ...
2
by: RobertHillEDS | last post by:
While using the Soap generated ASP code, I would like to dump the raw contents of the request and response objects using Response.AppendToLog. I have tried using variations of the following code,...
3
by: Farooq Khan | last post by:
why does Response.Write in a method of code-beind class when called from inpage code (i.e in <%---%>), after creating object of that class, fails when called while it works perfectly ok while...
5
by: Michael | last post by:
Hello, I have a separate Database class that handles any database work that all my asp.net pages can use. My problem is, many times I use try/catch to catch errors, and I want to output these...
4
by: Jit Prasad | last post by:
I have been consuming a IBM Websphere (Java) web service using .Net 1.0 front end writen in VB.NET. The proxy class submits a soap request and gets a soap response. When I migrated the front-end...
4
by: mike.biang | last post by:
I have an ASP page that is using an XMLHTTP object to request various pages from my server. I keep a single session throughout the XMLHTTP requests by bassing the ASPSESSIONID cookie through the...
2
by: Michael D. Ober | last post by:
When I single step through the code below, it sends back the PDF file that is retrieved in the line fm.GetAccountPDF(...). When I run without single stepping, I get the master page for this page. ...
6
by: mike.gilmore | last post by:
Hi, I'm trying to move all my custom validation code into the master page. Unfortunately anytime I use the response, request, or trace objects in any master page module (other than page_load), ...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.