获得页面输出结果
protected override void Render(HtmlTextWriter writer)
{
Stopwatch stopwatch = new Stopwatch();
stopwatch.Reset();
stopwatch.Start();
try
{
//会把页面的输出结果存储在这个StringBuilder中
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
HtmlTextWriter htw = new HtmlTextWriter(sw);
base.Render(htw);
string content = sb.ToString();
//重新写入页面
writer.Write(content);
}
catch (Exception ex)
{
Response.Write(ex.ToString());
Response.End();
}
finally
{
stopwatch.Stop();
Response.Write("runtime:" + stopwatch.ElapsedMilliseconds.ToString() + "ms");
}
}
{
Stopwatch stopwatch = new Stopwatch();
stopwatch.Reset();
stopwatch.Start();
try
{
//会把页面的输出结果存储在这个StringBuilder中
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
HtmlTextWriter htw = new HtmlTextWriter(sw);
base.Render(htw);
string content = sb.ToString();
//重新写入页面
writer.Write(content);
}
catch (Exception ex)
{
Response.Write(ex.ToString());
Response.End();
}
finally
{
stopwatch.Stop();
Response.Write("runtime:" + stopwatch.ElapsedMilliseconds.ToString() + "ms");
}
}
作者:Lance
出处:http://www.cnblogs.com/nuaalfm/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。