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")) ); }
今天又学了一招。