One of the downsides of turning off the buffer (you could use Flush but I really don't get why you'd do that in this scenario) is that the Client doesn't learn what the Content length at the start of the download. Hence the browsers dialog at the other end is less meaningfull, it can't tell how much progress has been made.
A better (IMO) alternative is to write the desired content to a temporary file (perhaps using GUID for the file name) then sending a Redirect to the client pointing at this temporary file.
There are a number of reasons why this approach is better:-
- The client gets good progress info in the save dialog or application receiving the data
- Some applications can make good use of byte range fetches which only work well when the server is delivering "static" content.
- The temporary file can be re-used to satisify requests from other clients
There are a number of downside though:-
- If takes sometime to create the file content, writing to a temporary file can therefore leave some latency before data is received and increasing the download time.
- If strong security is needed on the content having a static file lying around may be a concern although the use of a random GUID filename mitigates that somewhat
- There is need for some housekeeping on old temporary files.