Example #1
0
        public void Down(DownloadEventArgs e)
        {
            Console.WriteLine(BaseHelper.IsRemote);


            var file = this.OnDownloadFunc(e);

            try
            {
                HttpContext.Current.Response.ContentType = string.IsNullOrEmpty(file.ContentType) ? "application/x-excel" : file.ContentType;
                HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(file.FileName));
                HttpContext.Current.Response.WriteFile(Path.GetFullPath(file.FilePath));
            }
            catch (Exception)
            {
                throw new Exception("文件下载失败....");
            }
        }
Example #2
0
        protected virtual DownLoad OnDownloadFunc(DownloadEventArgs e)
        {
            DownLoadEventHander handler = DownloadFunc;

            return(handler?.Invoke(this, e));
        }