Translate

Monday, October 7, 2013

Send bytes to web client as download


//Setup HttpResponse headers
Response.Clear();
Response.ClearHeaders();
Response.ContentType = "mime-type";
Response.AddHeader("Content-Disposition", "attachment;filename=a_filename.ext");

// Put pdf in OutputStream
//pdf.Save(Response.OutputStream);
// Put image in OutputStream
//bitmap.Save(Response.OutputStream);
// Put bytes in OutputStream
//Response.OutputStream.Write(Bytes[], 0, Bytes.Length);
//Response.BinaryWrite(Bytes[]);
// Put string in OutputStream
//Response.Write(System.Text.Encoding.ASCII.GetString(Bytes[]));

// Send to client
Response.End();
//Response.Flush();