public static void PushToBrowser(BrowserContentType contentType, string downloadAsFilename, byte[] content) { HttpResponse response = HttpContext.Current.Response; response.Clear(); response.ClearContent(); response.ClearHeaders(); response.ContentType = contentType.GetCode(); response.AddHeader("Content-Disposition", String.Format("attachment; filename=\"{0}\"", downloadAsFilename)); byte[] fileContents = content; if (fileContents != null && fileContents.Length > 0) { response.BinaryWrite(fileContents); } response.Flush(); response.SuppressContent = true; response.Close(); }
public static void PushToBrowser(BrowserContentType contentType, string downloadAsFilename, string fileserverFilename) { PushToBrowser(contentType, downloadAsFilename, File.ReadAllBytes(fileserverFilename)); }