Intercept what is written to HttpResponse.OutputStream

I am working on a tool that checks access to an existing web application. There are no hooks in place in the existing application, but my plan is to introduce IHttpModule by changing the web.config file and write down everything I need to register during the EndRequest event.

What I'm struggling with right now: I can't intercept what is written in the output stream. I need to know what output the application sends to the client. Initially, I was hoping that I could run the code in BeginRequest to replace HttpContext.Response.OutputStream its own stream, which will be cleared to the original stream during EndRequest , but the stream has only get accessor, so I cannot replace it.

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

Can anyone here think of a better way to select the contents of what is written to this stream?

0
source share

Source: https://habr.com/ru/post/1012455/


All Articles