How to download a stream into a document.
Response.Clear();
Response.ContentType = "binary/octet-stream";//application
Response.AddHeader("Content-Disposition", "attachment; filename=Myfile.pdf ; size=" + b.Length.ToString());
Response.AddHeader("Content-Length", b.Length.ToString());
Response.BinaryWrite(b);
Response.End();
You might notice sometimes that the download attaches the text of the aspx page that you are using to download the document some times. This problem is caused by not setting the Length in the context line.
No comments:
Post a Comment