tags:

views:

86

answers:

2

I am working on a tool which audits access to existing web application. Existing app does not have any hooks in place, but my plan is to inject an IHttpModule by modifying web.config and log whatever I need to log during EndRequest event.

What I'm struggling with right now is: I cannot intercept what is application writing to an output stream. I need to know what output does the application send to the client. Originally, I hoped I could run a code in BeginRequest to replace HttpContext.Response.OutputStream with a stream of my own, which would be flushed to original stream during EndRequest, but the stream only has a get accessor, so I cannot replace it.

I could of course use reflection to assign to private member of HttpContext.

Can anyone here think of a better way to tee up contents of what is being written to a given stream?

+1  A: 

See this article for an example of how to implement a response filter: http://aspnetresources.com/articles/HttpFilters.aspx

M4N