public void SaveSofaXML(object s, EventArgs e)
{
HttpResponse response = HttpContext.Current.Response;
StreamReader streamReader = new StreamReader(
Server.MapPath("~/SentinelOperationsUI/SoFaXML.html"));
string text = streamReader.ReadToEnd();
streamReader.Close();
response.StatusCode = 200;
response.ContentEncoding = Encoding.UTF32;
response.AddHeader("content-disposition", "attachment; filename=test.html");
response.AddHeader("Content-Transfer-Encoding", "binary");
response.AddHeader("Content-Length",
response.ContentEncoding.GetByteCount(text).ToString());
response.ContentType = "application-download";
}
我认为我在正确的轨道上。但是当我尝试保存 html 文件(~100kb)时,文件永远不会完成下载。我错过了一些必需的标题吗?谢谢