ASP.Net最终渲染页面事件 [英] ASP.Net Final Rendering Page Event

查看:515
本文介绍了ASP.Net最终渲染页面事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

也许在输出缓存输出缓存我的previous问题太复杂

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

让我们简化。

我如何从一个页面得到最终,准备发送呈现的HTML(或控制)的ASP.Net事件?我认为这将是将用于输出缓存相同的内容,所以可以进行查询以找出将要被放置到高速缓存中。

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从复制:
的http:// ASP code .NET /最后一秒-HTML的变化,在你的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(); 
            } 
        } 
    } 
} 

这篇关于ASP.Net最终渲染页面事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆