In C# your code for as much might look like so:
byte[] bytes = File.ReadAllBytes(pathToFlatFile);
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=foo.txt";
HttpContext.Current.Response.AddHeader("Content-Length", bytes.Length.ToString());
HttpContext.Current.Response.ContentType = "text/plain";
HttpContext.Current.Response.OutputStream.Write(bytes, 0, bytes.Length);
HttpContext.Current.Response.Flush();
This suggests that the solution is to chase the lines above with:
HttpContext.Current.Response.End();
...but I put the line with the .End(); immediately before the line with the .Flush(); and that seemed to work too!
No comments:
Post a Comment