I would like to share a way by which server may transfer the data to client in chunks rather than sending entire data.

This approach is useful when we have large data at server and client is waiting for entire page to be display. Because by default buffering is enabled in which means that all the output from your ASP is actually sent to the browser only when the page completes its processing.


In this article we will learn following thing

·     Response.flush

Problem Statement

Client might have to wait until all the processing get completed on server, because server will send response back to client only when page completes its processing.

1)       If server is taking lot of time to process the request then Client has to wait for long time which is not good approach.

2)       Servers have to retain huge amount of data at memory.


Now as know, by default buffering is enabled so client must have to wait until all the processing done by server.

We can use Response.flush to send the buffered output to client.

Response.flush method is used to send buffered output immediately when the Response.Buffer is set true.

By default it is Response.Buffer= true.

Consider following line of code.

for (int i = 0; i < 100; i++)
   Response.Write(i + "\n");      


Here in this code client have to wait for 100 sec because Thread.Sleep(1000)= 1 sec

and we have loop for 0 to 99. So in above code Client has to wait which is not a


Using Response.flush
for (int i = 0; i < 100; i++)
                Response.Write(i + "\n");


Here from above code, Client do not need to wait for 100 sec, client will get output

on each and every second.

Data will be transferred to client in chunks. We would see updated screen after

each and every second.

When I debug the Httprequest and Httpresponse, found that data has been

transferred in chunk.

Following is the snap shot for above solution approach. Here we can see Transfer-

encoding : Chunked.

Getting Data in chunks from server

  Modified On Sep-07-2019 12:14:40 AM

Leave Comment