码迷,mamicode.com
首页 > 其他好文 > 详细

发送请求,让服务器的某个文件下载

时间:2015-08-17 13:47:35      阅读:127      评论:0      收藏:0      [点我收藏+]

标签:

Js:发送异步请求:

window.location.href = "/Log/DownloadExcel?Excel=" + data;

Controller:

public ActionResult DownloadExcel()
        {
            string excel = Request.QueryString["Excel"] ?? "";
            //if (excel == "")
            //{
            //    return;
            //}
            string path = System.Web.HttpContext.Current.Server.MapPath("~/Excel");
            string filepath = string.Format("{0}\\{1}", path, excel);
            string name = Path.GetFileName(filepath);
            return File(filepath, "application/x-zip-compressed", name);
        }

发送请求,让服务器的某个文件下载

标签:

原文地址:http://www.cnblogs.com/zychengzhiit1/p/4736197.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!