I have this following code for bringing page attachments to the user:
private void GetFile(string package, string filename)
{
var stream = new MemoryStre
Take a look a this: Writing MemoryStream to Response Object
I had the same problem and the only solution that worked for me was:
Response.Clear();
Response.ContentType = "Application/msword";
Response.AddHeader("Content-Disposition", "attachment; filename=myfile.docx");
Response.BinaryWrite(myMemoryStream.ToArray());
// myMemoryStream.WriteTo(Response.OutputStream); //works too
Response.Flush();
Response.Close();
Response.End();