Response.Close()

I found myself researching Response.Close() recently because of an issue with streaming attachments back to the browser.

This code had always worked, but in one particular environment we found that not all of the data was making it through the BinaryWrite:

Response.Buffer = False
Response.ClearHeaders()
Response.ContentType = File.FileType
Response.AddHeader("Content-Disposition", "attachment; filename=" & File.FileName)
Response.BinaryWrite(File.FileData)
Response.Close()
Response.End()

Removing the Response.Close() fixed it. The cause was most likely the load balancer in that environment, which the other environments did not have.

Leaving Response.Close() out works in every situation I have run into, so I standardized on not using it unless there is a specific reason to.