Reputation: 35194
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";
}
I think im on the right track. But when i try do save the html file (~100kb) the file never finishes downloading. Did i miss some required headers? Thanks
Upvotes: 1
Views: 250
Reputation: 148524
try this:
Response.AppendHeader("content-disposition", "attachment; filename=test.html");
Response.TransmitFile(Server.MapPath("~/SentinelOperationsUI/SoFaXML.html"));
Response.End();
Upvotes: 4