Use HttpApplication.CompleteRequest Instead of Response.End

Use HttpApplication.CompleteRequest Instead of Response.End

 

HttpApplication.CompleteRequest is preferable to use for aborting a request in an ASP.NET application over Response.End, because it has better performance characteristics.  If you’re using Response.End, you’ve probably at one time or another encountered the ThreadAbortException that goes along with it.

 

The behavior of CompleteRequest changed with 2.0, as Rick describes here.  However, the reason why you’ll most likely want to call CompleteRequest rather than Response.End is that, while it still short-circuits the ASP.NET pipeline (jumping immediately to the EndRequest event), it does so without throwing a ThreadAbortException.

 

http://stevesmithblog.com/blog/use-httpapplication-completerequest-instead-of-response-end/

posted @ 2010-03-19 12:53  octoberfirst  阅读(388)  评论(0编辑  收藏  举报