[How Do I:] Use the Reponse.Filter Property to Replace HTML in an ASP.NET Page
by Chris Pels
In this video Chris Pels shows how to use the Reponse.Filter property to intercept and alter the HTML being sent to a page. First, a sample page is created with some simple text. Then, a custom Stream class is created which serves as the replacement stream for the current stream being sent to the user’s browser. In that custom stream class the contents of the page are retrieved from the stream, altered, and then written out to the response stream. In this custom Stream class the Write method is customized to replace the HTML in the base Response stream, thereby altering what is sent to the user’s browser. Finally, the new stream class is assigned to the Response.Filter property in the Page_Load event, thereby, providing the mechanism for altering the page content.
|