HttpContext.Current.Response.Buffer = false;
HttpContext.Current.Response.Charset = string.Empty;
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=Ro.csv");
HttpContext.Current.Response.AddHeader("Pragma", "public");
HttpContext.Current.Response.ContentType = "application/force-download\n";
this.EnableViewState = false;
int i = 0;
while (i < RO.Count)
{
roDataRow = (Business.RO)ROi];
if (i == 0)
{
HttpContext.Current.Response.Write(roDataRow.GetCSVFieldNames(isSalesReport));
}
HttpContext.Current.Response.Write(roDataRow.ToCSVString(isSalesReport));
i++;
}
HttpContext.Current.Response.Flush();
this.Context.ApplicationInstance.CompleteRequest();
Session["ReportData"] = null;
由于IN IE10 CSV下载失败,我更换了HttpContext.Current.Response.Close(); with this.Context.ApplicationInstance.CompleteRequest();下载问题已解决,但下载的文件附加了html内容。如何使html内容不附加到下载文件