예제 #1
0
        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();
        }
예제 #2
0
 public static void PushToBrowser(BrowserContentType contentType, string downloadAsFilename, string fileserverFilename)
 {
     PushToBrowser(contentType, downloadAsFilename, File.ReadAllBytes(fileserverFilename));
 }