File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -968,14 +968,21 @@ private void StreamFile(string FilePath, string DownloadAs)
968968 DownloadAs = DownloadAs . Replace ( " " , "_" ) ;
969969
970970 System . IO . FileInfo objFile = new System . IO . FileInfo ( FilePath ) ;
971- System . Web . HttpResponse objResponse = System . Web . HttpContext . Current . Response ;
972- objResponse . ClearContent ( ) ;
973- objResponse . ClearHeaders ( ) ;
974-
975- objResponse . AppendHeader ( "Content-Type" , MimeMapping . GetMimeMapping ( objFile . Extension ) ) ;
976- objResponse . AppendHeader ( "Content-Disposition" , "attachment; filename=" + DownloadAs ) ;
977- objResponse . AppendHeader ( "Content-Length" , objFile . Length . ToString ( ) ) ;
978- objResponse . TransmitFile ( objFile . FullName ) ;
971+
972+ var b = File . ReadAllBytes ( FilePath ) ;
973+
974+ var Response = System . Web . HttpContext . Current . Response ;
975+
976+ Response . Clear ( ) ;
977+ Response . ContentType = MimeMapping . GetMimeMapping ( objFile . Extension ) ;
978+ Response . AppendHeader ( "Content-Disposition" , "attachment; filename=" + DownloadAs ) ;
979+ Response . AddHeader ( "Content-Length" , b . Length . ToString ( ) ) ;
980+ Response . Flush ( ) ;
981+ Response . BinaryWrite ( b ) ;
982+
983+ HttpContext . Current . Response . Flush ( ) ;
984+ HttpContext . Current . Response . SuppressContent = true ;
985+ HttpContext . Current . ApplicationInstance . CompleteRequest ( ) ;
979986 }
980987
981988 #endregion
You can’t perform that action at this time.
0 commit comments