ASP.NET downloading large files of unknown size <p>I want to use <a href="http://en.wikipedia.org/wiki/ASP.NET" rel="nofollow noreferrer">ASP.NET</a> and <a href="http://en.wikipedia.org/wiki/Internet_Information_Services" rel="nofollow noreferrer">IIS</a> to download dynamically generated files to the browser to be saved. I don't know the size of the file that will be generated.</p> <p>In the current form, my code generates data and uses HttpResponse.Write() to send to the client. But the client sees no activity for about a minute, before finally showing the save file dialog.</p> <p>By default, IIS buffers the output to be sent to the client. It is possible to turn this off, but that doesn't help in my case. The problem seems to be the way IIS chooses to format the packets.</p> <p>If the file size is known ahead of time, then I could set the Content-length in the header. If I turned off output buffering, then presumably, IIS can start sending to the client right away.</p> <p>But since I don't know the file size, IIS seems to be buffering the output until a certain limit is reached (packet size or time, I don't know), then sends a packet with Transfer-encoding set to chunked.</p> <p>I could try chunking the data myself, but is there a way to get IIS to perform the chunking, but with a smaller packet size so that the dialog shows sooner?</p>