所以,我试图传输一个文件到客户端。继其他一些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结果,然后在页面的源代码,其中包含我的按钮被附加到该文件。
我必须等待10-15分钟才能接受答案。我也试图理解这两个答案之间的差异是否相关。 –