I have a HttpHandler that I\'m using to handle certain images on a client\'s website. When I\'m outputting the image stream to the response object and call Flush occasionally an
I realise this is an old post but it came up when I was looking for an answer to a similar issue. The following is largely verbatim from this SO answer. More background info is available at Is Response.End() considered harmful?.
Replace this: HttpContext.Current.Response.End();
With this:
HttpContext.Current.Response.SuppressContent = true; // Gets or sets a value indicating whether to send HTTP content to the client.
HttpContext.Current.ApplicationInstance.CompleteRequest(); // Causes ASP.NET to bypass all events and filtering in the HTTP pipeline chain of execution and directly execute the EndRequest event.