return File

        public ActionResult DownloadMessage()
        {
            string strExportData = "无数据!";            
            byte[] data = System.Text.Encoding.GetEncoding("GB2312").GetBytes(strExportData);
            return File
                (
                    data,
                    "application/x-msexcel",
                    string.Format("ErrorInfo_{0}.csv",
                    DateTime.Now.ToString("yyyyMMddHHmmss"))
                );
        }

Today we learned a trick.

Reproduced in: https: //www.cnblogs.com/ushou/p/3419588.html

Guess you like

Origin blog.csdn.net/weixin_34306446/article/details/93162570