【发布时间】:2011-11-17 05:27:18
【问题描述】:
我有一个处理程序,它可以正常工作以提供下载服务。这是重要的代码:
// Get size of file
FileInfo f = new FileInfo(Settings.ReleaseFileLocation + ActualFileName);
long FileSize = f.Length;
// Init (returns ID of tblDownloadLog record created with blank end date)
int DownloadRecordID = Constructor.VersionReleaseDownload.newReleaseDownload(ActualFileName);
context.Response.Clear();
context.Response.Buffer = false;
context.Response.ContentType = "application/octet-stream";
context.Response.AddHeader("Content-Disposition", "attachment; filename=" + OriginalFileName);
context.Response.AddHeader("Content-Length", FileSize.ToString());
context.Response.TransmitFile(Settings.ReleaseFileLocation + ActualFileName);
context.Response.Close();
// Complete download log, fills out the end date
Constructor.VersionReleaseDownload.completeReleaseDownload(DownloadRecordID);
context.Response.Close(); 确保 completeReleaseDownload() 仅在下载完成时运行,这非常有用(re Only count a download once it's served)
问题是,我们会在大约相同的时间间隔内收到大量来自相同 IP 地址的日志。在深入挖掘之后,他们似乎是使用 Download Resumer 软件的用户。
当我尝试使用下载恢复器时,它似乎失败了。我的问题是:
- 如何检测这是部分请求
- 如何处理部分请求
- 如何使其与上述代码一起工作,以便 a) 在第一个部分 get 上调用
https://www.scirra.com/downloads/releases/construct2-r68-setup_4.exe,b) 在最后一个部分 get 上调用completeReleaseDownload?
【问题讨论】:
-
我想这会回答你的问题stackoverflow.com/questions/5429947/…
标签: c# asp.net http-headers download partial