Capturing the Output of ASP.NET Pages
If you want to add a signature (for whatever purpose) to all pages your ASP.NET app serves to the browser, you can write an application event handler to intercept the EndRequest event or, better yet, the PreSendRequestContent event. The latter, in fact, occurs just before the HTTP content is sent to the browser; the former is the last chance you have to send text to the browser during the request.
For a (too) long time, I made myself convinced that a PreSendRequestContent handler would have offered the opportunity to modify the outgoing markup. All application events like EndRequest and PreSendRequestContent provide access to the HTTP context and, from here, to the response object stream--the OutputStream property of the HttpResponse class.
The problem is that the response's output stream is write-only, presumably for performance reasons. Any attempt to read the output stream fails. The actual class is an internal class named HttpResponseStream in which CanRead and CanSeek return false and length and position functions (required by Stream-based classes) just throw a NotSupported exception.
If you simply want to append text to the request's response, an application event (either in global.asax or in a HTTP module) is fine. If you want to process the content outside the page code, use a response filter object.
A response filter object is a custom Stream that you register with the Filter property of the HttpResponse object. This content of the output stream is passed through this stream before the PreSendRequestContent event occurs. In this way, you can modify the content of the page at will.
This is the only way you (seem to) have in ASP.NET 1.x to capture the output of a Web page. To do what?
I've found trick of essential importance to enhance the trace output of a page.