Failed - network error while loading zip file made by Ionic.Zip.dll

I am trying to download a zip file made Ionic.Zip.dllfrom an asp.net c # web form application as follows:

zip.AddEntry("filename", arraybyte);
Response.Clear();
Response.BufferOutput = false;
Response.ContentType = "application/zip";
Response.AddHeader("content-disposition", "filename=SuppliersDocuments.zip");
zip.Save(Response.OutputStream);
Response.Close();

But I get Failed - network erroras follows:

enter image description here

The error occurs only in chrome , and it works correctly in other browsers. The error does not occur on my local host, and this only happens on the main server.

It would be very helpful if someone could explain the solution to this problem.

+4
source share
1 answer

, Chrome. Chrome v53 , .

, Content-Length .

string fileName = string.Format("Download.zip");
Response.BufferOutput = false;  // for large files  
using (ZipFile zip = new ZipFile())
{
      zip.AddFile(path, "Download");
      Response.Clear();
      Response.Buffer = true;
      Response.ContentType = "application/zip";
      Response.AddHeader(name: "Content-Disposition", value: "attachment;filename=" + fileName);
      Int64 fileSizeInBytes = new FileInfo(path).Length;
      Response.AddHeader("Content-Length", fileSizeInBytes.ToString());                                    
      zip.Save(Response.OutputStream);
      Response.Flush();
}
Response.Close();
0

Source: https://habr.com/ru/post/1670154/


All Articles