简体   繁体   中英

ASP.Net Final Rendering Page Event

Perhaps my previous question on output caching output caching was too complex.

Let's simplify.

How can I get the final, "ready for sending" rendered HTML from a page (or control) event in ASP.Net? I assume that this will be the same content that will be used for the output cache, so could be queried to find out what is about to be placed into the cache.

Code copied from: http://aspcode.net/Last-second-HTML-changes-in-your-ASPNET-page.aspx

protected override void Render(HtmlTextWriter writer) 
{ 
    using(System.IO.MemoryStream msOur = new System.IO.MemoryStream()) 
    { 
        using(System.IO.StreamWriter swOur = new System.IO.StreamWriter(msOur)) 
        { 
            HtmlTextWriter ourWriter = new HtmlTextWriter(swOur); 
            base.Render(ourWriter); 
            ourWriter.Flush(); 
            msOur.Position = 0; 
            using(System.IO.StreamReader oReader = new System.IO.StreamReader(msOur)) 
            { 
                string sTxt = oReader.ReadToEnd();                     
                Response.Write(sTxt); 
                oReader.Close(); 
            } 
        } 
    } 
} 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM