【问题标题】:IIS/ASP file download different to originalIIS/ASP 文件下载与原始文件不同
【发布时间】:2013-09-20 04:25:07
【问题描述】:

在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"));

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

【问题讨论】:

    标签: asp.net http iis download


    【解决方案1】:

    这似乎可以解决问题:

    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"));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-25
      • 2017-12-14
      相关资源
      最近更新 更多