在download_pdf.aspx的page_load事件中我写了以下
Response.ClearHeaders();
Response.ClearContent();
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Disposition", "filename=1.pdf");
Response.WriteFile(@"d:\List.pdf");
Response.Flush();
Response.End();
Response.AddHeader("Content-Disposition", "attachment;filename=1.pdf");
就可以了
fileName ="A.pdf";
FileStream fs = new FileStream(strFilePath, FileMode.Open);
byte[] bytes = new byte[(int)fs.Length];
fs.Read(bytes, 0, bytes.Length);
fs.Close();
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
Response.BinaryWrite(bytes);
Response.Flush();
Response.End();