Sunday, April 1, 2012

Thread Exception while trying to use HttpContext.Current.Response.End()

Hello All,

We frequently got Thread Exception when using HttpContext.Current.Response.End(). The error is shown below:

Source:mscorlib, Message:Thread was being aborted., StackTracke:   at System.Threading.Thread.AbortInternal()     at System.Threading.Thread.Abort(Object stateInfo)     at System.Web.HttpResponse.End()

This is a known issue when we use methods like HttpContext.Current.Response.End(), HttpContext.Current.Response.Redirect() and Server.Transfer() (Refer Microsoft Support)

The workaroud is to use HttpContext.Current.ApplicationInstance.CompleteRequest instead of Response.End()

Cheers !


  1. Thanks a lot it saved my day !!!

  2. instead of Response.End you can use.
    HttpContext.Current.Response.Flush(); // Sends all currently buffered output to the client.
    HttpContext.Current.Response.SuppressContent = true; // Gets or sets a value indicating whether to send HTTP content to the client.