I have asp.net c# code which, on click, creates a zip file including some excel files generated on the fly.
The code works fine in Internet Explorer, the zip file is downloadable and the files inside open correctly.
However when i click the button in Chrome or firefox, there is no luck and all that happens is that the page refreshs with the letters PK at the top.
below is an exerpt of what is happening;
using (ZipFile zipFile = new ZipFile())
foreach (var lll in List)
Class currentClass = DBMLManager.Instance.ABC(lll.ID);
if (currentClass.Type == "THIS_TYPE")
List<uspProcClass> Details = Manager.Instance.Report(ID, lll.ID);
if (Details.Count > 0)
string fileName = "Report.pdf";
MemoryStream myMemoryStream = new MemoryStream();
MemoryStream newMemoryStream = Invoice.GenerateInvoiceForZip(lll.ID, myMemoryStream);
byte docDat = newMemoryStream.ToArray();
HttpContext.Current.Response.ContentType = "application/PDF";
HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment; filename=testdoc.pdf"));
Response.AppendHeader("content-disposition", "attachment; filename=" + zipName + ".zip");
From memory, Response.End() doesn't flush the buffer response buffer. You can either disable the response buffer with "Response.BufferOutput = false;", or call something like Response.OutputStream.Flush(), or end the response cleanly with HttpApplication.CompleteRequest.
There's a similar thread at
which might be useful.
Hope this helps.