【发布时间】:2015-11-24 20:20:46
【问题描述】:
所以,我正在尝试向客户端传输文件。在其他一些 SO 答案之后,我目前有以下代码(sb 是 StringBuilder):
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=export.csv");
HttpContext.Current.Response.ContentType = "text/csv";
HttpContext.Current.Response.Write(sb.ToString());
但是,我的问题是我得到了 expeted 结果,然后将包含我的按钮的页面的源代码附加到文件中。
【问题讨论】:
标签: c# asp.net attachment