每次下载文件而不是在新标签页中打开。我的代码是:
protected void bttnpdf_Click(object sender, EventArgs e)
{
string FilePath = Server.MapPath("Road map.docx");
WebClient User = new WebClient();
Byte[] FileBuffer = User.DownloadData(FilePath);
if (FileBuffer != null)
{
Response.ContentType = " application/vnd.openxmlformats-
officedocument.wordprocessingml.document";
Response.AddHeader("content-length", FileBuffer.Length.ToString());
Response.BinaryWrite(FileBuffer);
}
}