0

在 IIS/ASP 下有如下代码,在 Windows 下用 Chrome 浏览器:

Response.ContentType = "application/exe";  //also tried application/octet-stream
Response.AddHeader("content-disposition", "attachment;filename=MyFile.exe");
Response.TransmitFile(Server.MapPath("~/MyFile.exe"));

但是,当我完成下载时,我下载的文件与原始文件大小不同(下载的文件更大),并且缺少数字签名。我该如何解决?

4

1 回答 1

0

这似乎可以解决问题:

FileInfo info = new FileInfo(Server.MapPath("~/MyFile.exe"));
Response.ContentType = "application/octet-stream";
Response.AddHeader("content-length", info.Length.ToString());
Response.AddHeader("content-disposition", "attachment;filename=MyFile.exe");
Response.TransmitFile(Server.MapPath("~/MyFile.exe"));
于 2013-09-20T04:37:15.580 回答