I am trying to export a Crystal ReportDocument using ExportToHttpResponse
like so:
report.ExportToHttpResponse(exportOptions, HttpContext.Current.Response, true, "test");
When I first tried to run this, I received a System.Threading.ThreadAbortException
. After reading about how this is a known error with ExportToHttpResponse
in this question, I tried implementing the suggested workaround of wrapping the statement in a try/catch block like so:
try
{
report.ExportToHttpResponse(expOptions, HttpContext.Current.Response, true, "test");
}
catch (System.Threading.ThreadAbortException e)
{
}
As I understand it, this should catch and ignore the error, and proceed. However, I am still getting the System.Threading.ThreadAbortException
on the closing bracket of the catch statement. My question is why is the exception still being received even though I am apparently catching it, and how could I go about fixing it so that the exception is ignored?
You can catch the ThreadAbortException and call the Thread.REsetAbort method, to cancel the bubbling of the exception. However, keep in mind that response.end is a bad idea. Whenever you can try to call HttpApplication.CompleteRequest(), and read this SO question which proved really useful to me in this regard.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With