5

我有这个代码

private void writeReport(IReport report, string reportName)
{
    string reportString = report.makeReport();
    ASCIIEncoding encoding = new ASCIIEncoding();
    byte[] encodedReport = encoding.GetBytes(reportString);
    Response.ContentType = "text/plain";
    Response.AddHeader("Content-Disposition", "attachment;filename="+ reportName +".txt");
    Response.OutputStream.Write(encodedReport, 0, encodedReport.Length);
    Response.End();
}

但我有 3 个文件需要发送给客户。我宁愿不必让用户单击 3 个按钮来获取 3 个 txt 文件。有没有办法一次性发送所有 3 个?

4

2 回答 2

6

不,出于安全原因,不支持用于下载的多部分附件(如电子邮件中的附件)。它被称为“路过式下载”。

请注意,Gmail 通过动态压缩文件来处理此问题。你也应该。http://forums.asp.net/t/1240811.aspx

于 2009-07-03T08:27:17.347 回答
2

这可以根据motobit.com上的文章“在一个 http 请求中下载多个文件”来完成。

然而,这不是 HTTP 的设计方式,遵循这些步骤可能会随时中断,具体取决于客户端和服务器配置。

于 2010-11-29T03:26:45.780 回答