尝试将文件从服务器下载到客户端时出现问题。单击时,保存文件提示显示为应有的样子,但它不指向我要下载的文件,而是指向我的 aspx 页面?换句话说,它不会下载我想下载的文件,而是下载下载链接所在的页面。真的很奇怪......似乎我指定下载的文件被完全忽略/没有效果......
if (File.Exists(Server.MapPath(driversLocation + name + ".zip")))
{
FileInfo fileInfo = new FileInfo(Server.MapPath(driversLocation) + name + ".zip");
Response.Clear();
Response.AddHeader("Content-Disposition", "inline;attachment; filename=" + name + ".zip");
Response.AddHeader("Content-Length", fileInfo.Length.ToString());
Response.ContentType = "application/download";
Response.Flush();
Response.TransmitFile(Server.MapPath(driversLocation) + name + ".zip");
Response.End();
}
任何帮助,将不胜感激!