【发布时间】:2010-10-18 16:32:23
【问题描述】:
最初我试图弄清楚 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();
【问题讨论】:
标签: c# asp.net download httpresponse