页面执行时生成静态文件的方法
protected override void Render(HtmlTextWriter writer)
{
if (EnableStaticFile)
{
if (transferToHtml) return;
string authorPath = Server.MapPath("/authors/" + GetUrlPath(authorID) + ".html");
string authorDir = Path.GetDirectoryName(authorPath);
if (!Directory.Exists(authorDir))
{
Directory.CreateDirectory(authorDir);
}
TextWriter ioWriter = null;
HtmlTextWriter hioWriter = null;
try
{
ioWriter = new StreamWriter(authorPath, false, Response.ContentEncoding);
hioWriter = new HtmlTextWriter(ioWriter);
base.Render(hioWriter);
}
catch (Exception) { }
finally
{
if (ioWriter != null) ioWriter.Close();
if (hioWriter != null) hioWriter.Close();
}
}
base.Render(writer);
}


浙公网安备 33010602011771号