復制代碼 代碼如下:
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;
Application["runtime"] = (Convert.ToDouble((ts.Milliseconds)) / 1000);
}
在要顯示的地方: 頁面執行時間:
復制代碼 代碼如下:
<%=Convert.ToString(Application["runtime"]) %>
秒