.net 生成静态页

1.模板替换

2.重写Render 方法

    protected override void Render(HtmlTextWriter writer)
    {
        StringWriter sw = new StringWriter();
        base.Render(new HtmlTextWriter(sw));//获取正常输出的html

        string html = sw.ToString();
        writer.WriteLine(html.Trim());
        string filePath = Server.MapPath("t.html");
        StreamWriter streamWriter = new StreamWriter(filePath, false, Encoding.UTF8);
        streamWriter.Write(html);
        streamWriter.Close();
     }
 

posted @ 2011-03-16 10:41  微雨杏花村  阅读(187)  评论(0编辑  收藏  举报