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);
        }
posted on 2015-08-17 11:41  新猪先生  阅读(1211)  评论(2编辑  收藏  举报