I want to use ASP.NET and IIS to download dynamically generated files to the browser to be saved. I don't know the size of the file that will be generated.
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.
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.
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.
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.
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?