CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2006
    Posts
    141

    System.Threading.ThreadAbortException Error and Response.End

    Hi, I encounter the error when i use response.end for display my report.

    After refer to http://support.microsoft.com/default...b;en-us;312629 , i have change response.end to HttpContext.Current.ApplicationInstance.CompleteRequest() or remove the code, i do not encounter the error anymore but my report is not displayed.
    Does anyone has any idea on this ?

    my code is as below:
    Code:
    rptDataSource = GetRptSource(sEmployeeList, sLeaveType, sFrDate, sToDate)
                    ReportViewer1.LocalReport.DataSources.Add(rptDataSource)
                    ReportViewer1.LocalReport.EnableExternalImages = True
                    ReportViewer1.LocalReport.Refresh()
                    Dim mimeType As String = Nothing
                    Dim encoding As String = Nothing
                    Dim streams As String() = Nothing
                    Dim extension As String = Nothing
                    Dim warnings As Microsoft.Reporting.WebForms.Warning() = Nothing
                    Dim returnValue As Byte()
    
    
                    ' Call the Render Method To Deliver the Report With Out Preview
                    returnValue = ReportViewer1.LocalReport.Render("PDF", Nothing, mimeType, encoding, extension, streams, warnings)
                    Response.Buffer = True
                    Response.Clear()
                    Response.ContentType = "Application/pdf"
                    Response.AddHeader("content-disposition", "inline; filename=apr." + extension)
                    Response.BinaryWrite(returnValue)
                    Response.Flush()
                    'Response.End()

  2. #2
    Join Date
    Sep 2008
    Location
    Netherlands
    Posts
    865

    Re: System.Threading.ThreadAbortException Error and Response.End

    Change your code to try/catch block

    (C# syntax)
    Code:
    try{
      //your code here
    }
    catch(ThreadAbortException)
    {
      //ignore, cause by the Repsone.End
    }
    catch(Exception e){
      //do something with untwanted exceptions
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured