Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do we use Response.ClearHeaders()?

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

like image 748
Utkarsh Avatar asked Jul 06 '11 07:07

Utkarsh


1 Answers

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.

like image 126
Steve Avatar answered Sep 17 '22 23:09

Steve