2011-11-17 2 views
1

다운로드를 제공해야하는대로 작동하는 처리기가 있습니다.ASP.net C# partial get request

// 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();는 다운로드가

문제는 우리가 올 로그를 많이 얻고있다 (Only count a download once it's served 재) 매우 유용하다 완료되면 completeReleaseDownload() 만 실행 보장 : 이것은 중요한 코드입니다 같은 시간 간격으로 같은 IP 주소에서. 조금 더 파고 들자면 다운로드 소비자 소프트웨어를 사용하는 사용자 인 것으로 보입니다.

다운로드받는 사람을 사용하려고하면 실패 할 것 같습니다. 내 질문은 :

  • 나는 이것이 내가
  • 가 어떻게이가)에 https://www.scirra.com/downloads/releases/construct2-r68-setup_4.exe를 호출 그래서 위의 코드와 함께 작동 할 수있는 부분 요청을 처리 할 수있는 방법 부분 요청
  • 입니다 감지 어떻게 첫 번째 부분 수신 및 b) 마지막 부분 수신시 completeReleaseDownload 호출?
  • 이 전자 태그와 마임 달성된다
+0

나는이 질문 http://stackoverflow.com/questions/5429947/supporting-resumable-http-downloads-through-an-ashx-handler에 답을 생각하는 데 도움이 –

답변

2

, 체크 아웃 : 당신이 DownloadResumer을 사용하여 전송 된 일부 패킷을 캡처 할 때 http://www.devx.com/dotnet/Article/22533/1954

, 당신은 아마 범위 태그가 지정되고 있습니다.

범위 : 이것은 당신이이 부분 요청 있는지 확인하고 만약 그렇다면, 같은 조치를 취할 수 있습니다 500-1000

바이트 =

부울 isFirstRequest =의 RangeStart == 0; bool isLastRequest = RangeEnd == file.TotalBytes;

희망이