I’m trying to Flush a Zip file that has just been created, and have an issue with it:
a) it doesn’t actually Flush (I used the code before with the CSV files and all works well)
Here is the code:
outputMemStream.Position = 0;
System.Web.HttpResponse Resp = System.Web.HttpContext.Current.Response;
Resp.ClearContent();
Resp.ClearHeaders();
Resp.ContentType = "application/zip";
Resp.AddHeader("Content-Disposition", "attachment; filename=\"download.zip\"");
//byte[] buff = outputMemStream.ToArray();
//File.WriteAllBytes(path, buff);
outputMemStream.CopyTo(Resp.OutputStream);
outputMemStream.Close();
outputMemStream.Dispose();
Resp.Flush();
Resp.End();
The stream is created correctly because I am able to save it and can check it later that it looks alright.. just that thing that my browser doesn’t allow me to download it is quite annoying.
Cheers for your help!
This is probably the issue. The page is rendered both your file and your controls (including your “Export All” button).
Try moving the logic for downloading to a different page or handler that does nothing but return the file.