0

Windows で Chrome ブラウザーを使用して、IIS/ASP で次のコードを実行します。

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 に答える