Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get HTML before its sent to the browser

I would like to capture HTML before its gets sent to the browser for caching. Is there a way to do this?

like image 212
Luke101 Avatar asked Nov 21 '25 01:11

Luke101


1 Answers

I've never tried this, but could you hook into the EndRequest event of an HTTP module, and simply read the Response property?

Edit: Just tried this - massive fail, at least at a simple level, because the Response isn't readable at that point. Could still be viable if there's a way to redirect the output of the Response at the beginning of a request, and then pipe it through at the end.

Edit #2: I was close, but it's more complex than I thought. You need to implement a filter, which is demonstrated nicely here.

like image 73
jvenema Avatar answered Nov 22 '25 13:11

jvenema



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!