2013-03-31 1 views
-1

다음 코드를 사용하여 파일을 다운로드하고 있지만 Response.End은 항상 Exception을 발생 시켰습니다. 해당 비용은 내 애플리케이션 행동에 해당합니까? 그렇다면 어떻게하면 파일을 다운로드 할 수있는 다른 방법을 얻을 수 있습니다. 난 당신이 예외 던져 Response.End 함께 제공 비용을 지불하지 않으려면 파일Response.End() 사용 비용

try 
      { 
        DownloadFiles();      
        Response.End();     
      } 
      catch (ThreadAbortException) 
      { 
       // Thread.ResetAbort(); 
      } 
      catch (GSException ex) 
      { 
       Response.ClearHeaders(); 
       hdnResult.Value = ex.Message; 
       // ClientScript.RegisterStartupScript(this.Page.GetType(), "checkDownloadError", "window.parent.checkDownloadError('" + ex.Message + "');", true); 
      } 
      catch (Exception) 
      { 
       Response.ClearHeaders(); 
       hdnResult.Value = "Oops! Something unexpected happened. Please try again later"; 
       //ClientScript.RegisterStartupScript(this.Page.GetType(), "checkDownloadError", "window.parent.checkDownloadError('Oops! Something unexpected happened. Please try again later');", true); 
      } 
+0

예외는 무엇입니까? –

+0

스레드 중단 예외! –

+2

참조 : http://stackoverflow.com/questions/1087777/is-response-end-considered-harmful –

답변

1

에 추가 될 원치 않는 추가 데이터를 제외하지만,이 결과를 처리 할 수 ​​Thread.ResetAbort()를 사용하려고하면 사용할 수 대신 Application.CompleteRequest 메소드를 사용하십시오.