title: How to Avoid Response.End() "Thread was being aborted" Exception during the Excel file download
body: <p>I tried to convert my dataset into excel and  download that excel .I got my required excel file.But System.Threading.ThreadAbortException was raised every excel download.
  How to resolve this issue ?..
  Please help me...</p>
  
  <p>I call this method in my aspx screen.There also same exception has thrown by this method.</p>
  
  <p>I call that public void ExportDataSet(DataSet ds) function in many aspx screens and also I am maintaining  error logger method  for exceptions which are raised at runtime right those  exceptions are write  into  a .txt files. So that same exception  is logged in all the  aspx  screen's txt files.I just want to avoid this exception  throws from method declared class file to aspx. Simply i just want to handle this exception at my method declaration  class file itself.</p>
  
  <p>ASPX File Method call:
   excel.ExportDataSet(dsExcel);</p>
  
  <p>Method Definition:</p>
  
  <pre><code>public void ExportDataSet(DataSet ds)
  {
  
     try
     {
        string filename = "ExcelFile.xls";
        HttpResponse response = HttpContext.Current.Response;
        response.Clear();
        response.Charset = "";
        response.ContentType = "application/vnd.ms-excel";
        response.AddHeader("Content-Disposition", "attachment;filename=\"" + filename + "\"");
        using (StringWriter sw = new StringWriter())
        {
           using (HtmlTextWriter htw = new HtmlTextWriter(sw))
           {
               GridView dg = new GridView();
               dg.DataSource = ds.Tables[0];
               dg.DataBind();
               dg.RenderControl(htw);
               // response.Write(style);
               response.Write(sw.ToString());                                                
               response.End();                    // Exception was Raised at here
           }
        }
     }
     catch (Exception ex)
     {
        string Err = ex.Message.ToString();
        EsHelper.EsADLogger("HOQCMgmt.aspx ibtnExcelAll_Click()", ex.Message.ToString());
     }
     finally
     {                
     }
  }
  </code></pre>