我需要构建并向用户发送zip.
我已经看过做一个或另一个的例子,但不是两个,如果有任何"最佳实践"或任何事情,我很好奇.
对困惑感到抱歉.我将为Web用户动态生成zip,并在HTTP响应中将其发送给他们.不在电子邮件中.
标记
最初我试图找出Response.Close和Response.End之间的区别,但是在进行了更多的谷歌搜索和研究后,很明显我没有看到Byte []被发送回客户端的常见方式.我将在下面留下代码示例,但我想知道行业标准是做什么的.
Byte[] myBytes = GetReportBytes();
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.AppendHeader("content-length", myBytes.Length.ToString());
HttpContext.Current.Response.AppendHeader("content-Disposition", "attachment;filename=" + this.ReportFileName + GetReportExtension());
HttpContext.Current.Response.ContentType = GetApplicationContentType();
HttpContext.Current.Response.BinaryWrite(myBytes);
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.Close();
//CERT FIX
//HttpContext.Current.Response.End();
Run Code Online (Sandbox Code Playgroud)