【发布时间】:2018-07-10 19:34:29
【问题描述】:
我试图在浏览器上打开一个.docx 文件,但它被下载了。这很好,但是下载的.docx文件名不正确。
我正在使用 Chrome 浏览器和 ASP.NET C# 代码。
假设文件在网络路径//test/test.docx 和aspx 文件名DownloadTest.aspx 有下载word doc 代码。下载后,文件名为DownloadTest.docx,而不是test.docx。
下面是代码。
if (!this.IsPostBack)
{
string filePath = Request.QueryString["FN"];
Page.Title = filePath;
this.Response.ClearContent();
this.Response.ContentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
this.Response.AppendHeader("Content-Disposition;", "attachment;filename=" + Request.QueryString["FN"]);
this.Response.WriteFile(filePath);
this.Response.End();
}
【问题讨论】:
标签: asp.net