M
masoud bayan
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
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