try里Response.end()问题

问题

在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

posted @ 2017-05-11 23:06  talentzemin  阅读(243)  评论(0编辑  收藏  举报