1. 程式人生 > >try裏Response.end()問題

try裏Response.end()問題

abort con mic exceptio tps font stack src -a

問題

在xxx.aspx.cs中處理異步請求,大致代碼如下:

技術分享

但會發現始終會進catch。

原因

Response.End()會引發ThreadAbortException。

解決方案

使用HttpContext.Current.ApplicationInstance.CompleteRequest();代替

參考

官方文檔:https://msdn.microsoft.com/zh-cn/library/system.web.httpresponse.end.aspx

博客園:https://q.cnblogs.com/q/31506/

stackoverflow:http://stackoverflow.com/questions/20988445/how-to-avoid-response-end-thread-was-being-aborted-exception-during-the-exce

try裏Response.end()問題