文件下载

   public ActionResult DownAttachment(string dUrl, string fileName)
        {
            try
            {
                dUrl = HttpUtility.UrlDecode(dUrl);
                var bytes = new System.Net.WebClient().DownloadData(dUrl);
                Response.ContentType = "application/octet-stream";
                Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
                Response.BinaryWrite(bytes);
                Response.Flush();
                Response.End();
            }
            catch (Exception ex)
            {
                Response.Write("<script>alert('下载失败!远程服务器异常!');</script>");
            }
            return new EmptyResult();
        }
原文地址:https://www.cnblogs.com/wzq806341010/p/3346649.html