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()
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 !
Cheers !
Thanks a lot it saved my day !!!
ReplyDeleteGlad that this post helped u...Cheers !
Deleteinstead of Response.End you can use.
ReplyDeleteHttpContext.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.
HttpContext.Current.ApplicationInstance.CompleteRequest();