我查看了许多资源,以下应该可以工作,但是我的另存为对话框从未显示(不是特定于浏览器):
Response.ContentType = "application/octet-stream";
string downloadName = "Request "+request.RequestID+ "_researchExport.doc";
Response.AddHeader("Content-Length",
new System.IO.FileInfo(FileName).Length.ToString());
Response.AddHeader("Content-Disposition",
string.Format("attachment; filename={0};", downloadName));
Response.WriteFile(FileName);
Response.Flush();
Response.End();
该文件肯定存在。我还尝试了以下方法:
Response.TransmitFile(FileName)
改为使用离开了
Response.End()
省略
Content-Length
标题使用
this.ControllerContext.HttpContext.Response
任何帮助将不胜感激