Thursday, September 17, 2009

C#: Stream document to open within browser

Note: This is not full proof, flavor of browser and local settings would probably override things.

void StreamDocumentInline(byte[] content, string mimeType)
{
Response.Clear();
Response.Buffer = true;
Response.AddHeader("Content-Length", content.Length.ToString());
Response.AddHeader("Content-Type", mimeType);
Response.AddHeader("Content-Disposition", "inline");
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.