.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();
}
{
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();
}