Thursday, September 17, 2009

C#: Stream document through browser to open in native application

void StreamDocumentToNativeApp (byte[] content, string fileName, string mimeType)
{
Response.Clear();
Response.Buffer = true;
Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName);
Response.AddHeader("Content-Length", content.Length.ToString());
Response.AddHeader("Content-Type", mimeType); //Example application/text
Response.BinaryWrite(content);
Response.Flush();
Response.End();
}

No comments:

Post a Comment

Please use your common sense before making a comment, and I truly appreciate your constructive criticisms.