我正在使用以下代码下载文件,下载文件后它会打开我的网站页面,但它只能在 Firefox 浏览器中工作。它不适用于其他浏览器。
Response.AddHeader("Refresh", "3; url=http://www.mysite.com/");
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition", "attachment; filename=myfile.pdf");
Response.TransmitFile(Server.MapPath("myfile.pdf"));
Response.End();