Possible Duplicate:
How to create file and return it via FileResult in ASP.NET MVC?
ASP.NET MVC2: How to return a file from a controller?
I want to do this so the user can download the file from server.
public ActionResult Csv(int pid) { var csv = this.Repo.GetCsv(pid); var fileContents = Encoding.GetEncoding(1251).GetBytes(csv); return new FileContentResult(fileContents, "application/vnd.ms-excel") { FileDownloadName = "Report-" + pid + ".csv" }; }
精彩评论