在.net里得到一个asp.net页面的执行时间
2009-12-16 08:54 cnb_mtime 阅读(196) 评论(0) 编辑 收藏 举报Global.asax.cs中:
protected void Application_BeginRequest(Object sender, EventArgs e)
{
Application["StartTime"] = System.DateTime.Now;
}
protected void Application_EndRequest(Object sender, EventArgs e)
{
System.DateTime startTime = (System.DateTime)Application["StartTime"];
System.DateTime endTime = System.DateTime.Now;
System.TimeSpan ts = endTime - startTime;
Response.Write("<table border=0' width='100%'><tr><td align='center' width='100%'><font size=1 color='red'>页面执行耗时:" + ts + "秒<font></td></tr></table>");
}
{
Application["StartTime"] = System.DateTime.Now;
}
protected void Application_EndRequest(Object sender, EventArgs e)
{
System.DateTime startTime = (System.DateTime)Application["StartTime"];
System.DateTime endTime = System.DateTime.Now;
System.TimeSpan ts = endTime - startTime;
Response.Write("<table border=0' width='100%'><tr><td align='center' width='100%'><font size=1 color='red'>页面执行耗时:" + ts + "秒<font></td></tr></table>");
}