public ActionResult Download(){ var document = ... var cd = new System.Net.Mime.ContentDisposition { // for example foo.bak FileName = document.FileName, // always prompt the user for downloading, set to true if you want // the browser to try to show the file inline Inline = false, }; Response.AppendHeader("Content-Disposition", cd.ToString()); return File(document.Data, document.ContentType);}注意: 上面的此示例代码无法正确考虑文件名中的国际字符。有关相关的标准化,请参阅RFC6266。我相信ASP.Net
MVC的
File()方法和
ContentDispositionHeaderValue类的最新版本可以正确地解决此问题。-奥斯卡2016-02-25



