我正在尝试从屏幕上下载一些文本输出作为文本文件。以下是代码。它在某些页面上工作,而在其他页面上根本不工作。谁能建议这里有什么问题?
protected void Button18_Click(object sender, EventArgs e){
Response.Clear();
Response.Buffer = true;
Response.ContentType = "text/plain";
Response.AppendHeader("content-disposition", "attachment;filename=output.txt");
StringBuilder sb = new StringBuilder();
string output = "Output";
sb.Append(output);
sb.Append("\r\n");
Response.Write(sb.ToString());
}