当前位置:编程学习 > C#/ASP.NET >>

asp.net显示页面执行时间

答案:
复制代码 代码如下:

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"]) %>

上一个:ASP.NET 防止用户跳过登陆界面
下一个:在应用程序级别之外使用注册为allowDefinition=''MachineToApplication''的节是错误的

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,