Failed - network error when downloading excel file made by EPPlus.dll

Reza Amini picture Reza Amini · Sep 21, 2016 · Viewed 11.4k times · Source

I try to download an excel file made by EPPlus.dll from an asp.net c# web form application. but i get Failed - network error. It should be noted that mentioned error just occurs in chrome and the job can be done successfully in another browsers.

by the way this error does not occure on my localhost and it happens only on the main server.

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

http://www.irandnn.ir/blog/PostId/29/epplus

Answer

Nampally Dheeraj picture Nampally Dheeraj · Sep 21, 2016

I had the same problem when I was using Response.Clear() and Response.Close() and had to avoid them to look my code as below which is working.

Response.Buffer = true;
Response.ContentType = mimeType;
Response.AddHeader("Content-Disposition", "attachment; filename=" + nameOfFile);
Response.BinaryWrite(bytes);
Response.End();