コード例 #1
0
        public static void DownloadFile(this HttpResponse source, DownloadableFile file)
        {
            var contentData = file.ContentData.IsEmpty()
                                  ? file.ContentText.GetBytes(source.ContentEncoding)
                                  : file.ContentData;

            source.Clear();
            source.Buffer = false;
            source.AddHeader("Accept-Ranges", "bytes");
            source.AddHeader("Content-Disposition", "attachment;filename=\"" + file.FileName + "\"");
            source.AddHeader("Connection", "Keep-Alive");
            source.ContentType = file.ContentType;
            source.BinaryWrite(contentData);
            source.End();
        }
コード例 #2
0
        public static void DownloadFile(this HttpResponse source, DownloadableFile file)
        {
            var contentData = file.ContentData.IsEmpty()
                                  ? file.ContentText.GetBytes(source.ContentEncoding)
                                  : file.ContentData;


            source.Clear();
            source.Buffer = false;
            source.AddHeader("Accept-Ranges", "bytes");
            source.AddHeader("Content-Disposition", "attachment;filename=\"" + file.FileName + "\"");
            source.AddHeader("Connection", "Keep-Alive");
            source.ContentType = file.ContentType;
            source.BinaryWrite(contentData);
            source.End();
        }