[英]Try/Catch not catching System.Threading.ThreadAbortException in ReportDocument.ExportToHttpResponse
我試圖使用ExportToHttpResponse
導出Crystal ReportDocument, ExportToHttpResponse
所示:
report.ExportToHttpResponse(exportOptions, HttpContext.Current.Response, true, "test");
當我第一次嘗試運行它時,我收到了System.Threading.ThreadAbortException
。 在這個問題中閱讀了有關ExportToHttpResponse
的已知錯誤ExportToHttpResponse
,我嘗試實現了在try / catch塊中包裝語句的建議解決方法,如下所示:
try
{
report.ExportToHttpResponse(expOptions, HttpContext.Current.Response, true, "test");
}
catch (System.Threading.ThreadAbortException e)
{
}
據我了解,這應該捕獲並忽略錯誤,然后繼續。 但是,我仍然在catch語句的結束括號上獲得System.Threading.ThreadAbortException
。 我的問題是為什么即使我顯然正在捕獲它仍然會收到異常,我怎么能去修復它以便忽略異常?
您可以捕獲ThreadAbortException並調用Thread.REsetAbort方法,以取消異常的冒泡。 但是,請記住,response.end是一個壞主意。 無論什么時候你都可以嘗試調用HttpApplication.CompleteRequest(),並閱讀這個在這方面對我有用的SO問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.