效果图
后台代码
private void DownTxt() { try { StringBuilder sb = new StringBuilder(); for (int i = 0; i < 50000; i++) { sb.Append("测试i=" + i+" "); } Response.Clear(); Response.Headers["Content-Disposition"] = "attachment;filename=aaa.txt";//输出文件格式 Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8"); //解决乱码问题 Response.Write(sb.ToString()); } catch (Exception EX) { throw EX; } }