取得页面执行时间的代码
在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("页面执行时间:"+ ts.Milliseconds +" 毫秒");
}
{
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("页面执行时间:"+ ts.Milliseconds +" 毫秒");
}
posted on 2004-09-08 09:13 HelloSnoopy 阅读(401) 评论(0) 编辑 收藏 举报