Get rid of ThreadAbortException with httpResponse.End

Does anyone know how to replace httpResponse.End()

with something that doesn't throw ThreadAbortException

causing performance issues? Someone suggested doing "HttpContext.Current.ApplicationInstance.CompleteRequest ()", but that doesn't do everything it does httpResponse.End()

like sending buffered data to the client, which is a problem for me.

+3


source to share


2 answers


First, I doubt this is really causing serious problems. However, this is not a great idea at all ... it's actually an abuse of exceptions. (IMO, anyway.)

From the documentation :



This method is provided for ASP compatibility only, that is, for compatibility with the COM-based web programming technology that predates ASP.NET. If you want to go to the EndRequest event and send a response to the client, call CompleteRequest

.

Obviously the current method will still continue after being called CompleteRequest

, so you will need to make sure that you have fully handled the current event.

+3


source


Ok, I managed to find the answer here . If you go to "Jay Zalos" answer. I replaced httpResponse.End()

with the following 3 lines:



Response.Flush()
Response.SuppressContent = True
HttpContext.Current.ApplicationInstance.CompleteRequest()

      

+1


source







All Articles