Intercept what's being written to HttpResponse.OutputStream
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
, bu开发者_如何学运维t 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?
Check out Response.Filter.
http://www.west-wind.com/Weblog/ShowPost.aspx?id=72596&utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+koistya+%28RIA+Guy+%7C+Web+Development+News%29
See this article for an example of how to implement a response filter: http://aspnetresources.com/articles/HttpFilters.aspx
精彩评论