2017-12-29 12 views
0

로더가 화면에 표시되는 동안 버튼을 클릭하면 이 많아서 html에서 생성되었습니다. browser..there에서 생성 된 모든 압축 파일을 다운로드 한 후 은 내가다시 게시 할 때 로더를 시작하고 싶습니다. 다시 게시하면 중지됩니다.

코드 뒤에 .. 그래서 내가 이 제발 도와주세요 .. 로더를 막을 수 없다

Response.AddHeader("Content-Disposition", "attachment; filename=output.zip"); 
Response.TransmitFile(zipPath); 

를 사용해야합니다 :

protected void Button1_Click(object sender, EventArgs e) 
{ 
    string test = GetImportDetailsPDF("ImportFile(2)_2017.12.19-12.30.24.xlsx"); 
    //Generated all pdf files zipped and downloaded here 
    string startPath = Server.MapPath("/ImportPdf/"); 
    string zipPath = Server.MapPath("/ImportZip/result.zip"); 

    ZipFile.CreateFromDirectory(startPath, zipPath); 

    System.Web.HttpResponse response = System.Web.HttpContext.Current.Response; 
    response.ClearContent(); 
    response.Clear(); 
    Response.ContentType = "image/jpeg"; 
    Response.AddHeader("Content-Disposition", "attachment; filename=output.zip"); 
    Response.TransmitFile(zipPath); 

    HttpContext.Current.Response.Flush(); // Sends all currently buffered output to the client. 
    HttpContext.Current.Response.SuppressContent = true; // Gets or sets a value indicating whether to send HTTP content to the client. 
    HttpContext.Current.ApplicationInstance.CompleteRequest(); // Causes ASP.NET to bypass all events and filtering in the HTTP pipeline chain of execution and directly execute the EndRequest event. 
    HttpContext.Current.Response.End(); 
} 
public string GetImportDetailsPDF(string FileName) 
{ 
    //Here i have generated large amount of pdf generated from html page.. 
    return "Successfully Imported"; 
} 
+0

어떤 차단 도구를 사용하고 있습니까 ... 어떻게 시작 되나요? jQuery blockui 등 – DotNetDev

답변

0

클라이언트 측 솔루션Sys.WebForms.PageRequestManager을 기반으로 클래스를 시도해보십시오.

<!-- language: html --> 
    <script type="text/javascript"> 
     var prm = Sys.WebForms.PageRequestManager.getInstance(); 
     prm.add_initializeRequest(prm_InitializeRequest); 
     prm.add_endRequest(prm_EndRequest); 
     function prm_InitializeRequest(sender, args) { 
      //show screen blocker 
     } 
     function prm_EndRequest(sender, args) { 
      //hide screen blocker after a file is generated 
      //DoClick to download a prepared file 
     } 
    </script> 

UpdatePanel을 사용하면 파일 다운로드가 시작될 때까지 최종 사용자에게 포스트 백 속성이 표시되지 않습니다.

이 방법에 대한 자세한 설명을 확인하고이 해결책을 here으로 볼 수 있습니다.

+0

감사합니다 .. @ 블라디미르 –