I copied a code piece to send files to browser. I don't know why we use the lines written below cause removing these does not make any difference in my development environment.
Response.Clear();
Response.ClearHeaders();
Response.Buffer = false;
Can anyone provide a simple break down of the intended purpose & appropriateness of these.
Thanks
Response.Clear();
If you have written anything out already to the buffer, you'll need to clear that so extraneous content doesn't get included.
Response.ClearHeaders();
If the content type had been previously specified, for example, you probably don't want that. Any number of HTTP headers may have already been set - cache-control is another good example.
Response.Buffer = false;
No sense buffering the output if you're ready to dump the file out... just send it along and don't waste memory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With