locked
How to replace html using HttpModules ? RRS feed

  • Question

  • User493074690 posted

    I am trying to write an HttpModule (or something else) to replace specific content of any web page served by my web server. My initial requirement is to insert some javascript just before the </BODY> tag. I am trying to replace the </BODY> tag with the script + </BODY>. My future requirements include filtering and replacing specific words in the served pages with certain other words.

    Is HttpModules the right solution to achieve this ? I have written HttpModules in the past to authenticate users. Also, I could make it work to insert some text in the beginning or end of the response stream, but I could not make it work to insert some text in the middle or just before the </BODY> tag.

    Any suggestions would be appreciated.

    - Tony 

     

    Monday, October 8, 2007 4:23 PM

Answers

  • User-1426124666 posted

    Is HttpModules the right solution to achieve this ?
     

    They could be and to be honest there are a few methods that you could use that would work and would probably be classed as a valid method of achieving what you need. One of the methods I've used is Response Filters which could be a method that you would be interested in.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, October 9, 2007 5:46 AM