失败 - 网络错误中获取Zip文件中铬
问题描述:
我被Ionic.Zip.dll
像这样(ASP.NET,C#)创建一个zip:失败 - 网络错误中获取Zip文件中铬
zip.AddEntry("Document.jpeg", File.ReadAllBytes("Path");
我想这样的下载:
Response.Clear();
Response.BufferOutput = false;
Response.ContentType = "application/zip";
Response.AddHeader("content-disposition", "filename=SuppliersDocuments.zip";
zip.Save(Response.OutputStream);
Response.Close();
我在Firefox和Chrome的本地主机上测试了这段代码,它工作正常。但是当我在主机上测试此代码时,出现此错误:
Failed - network error
是我的代码错了吗?
答
我遇到了中继SSRS报告的类似问题。以@阿文的建议下,我做了以下内容:
private void CreateReport(string ReportFormat)
{
ReportViewer rview = new ReportViewer();
// (setup report viewer object)
// Run report
byte[] bytes = rview.ServerReport.Render(ReportFormat, deviceInfo, out mimeType, out encoding, out extension, out streamids, out warnings);
// Manually create a response
Response.Clear();
Response.ContentType = mimeType;
Response.AddHeader("Content-disposition", string.Format("attachment; filename={0}.{1}", fileName, extension));
// Ensure the content size is set correctly
Response.AddHeader("Content-Length", bytes.Length.ToString()); // <- important
// Write to the response body
Response.OutputStream.Write(bytes, 0, bytes.Length);
// (cleanup streams)
}
的修复程序。添加Content-Length头并将其设置为从报告服务的字节数组的大小。
尝试添加content-Size到响应标题。让我知道它是否有效。 – Kahbazi