获取页面加载时间(转载修改)
1.在Global.asax中添加如下
DateTime dt;
protected void Application_BeginRequest(Object sender, EventArgs E)
{
dt = DateTime.Now;
}
protected void Application_EndRequest(Object sender, EventArgs E)
{
DateTime dt2 = DateTime.Now;
TimeSpan ts = dt2 - dt;
Response.Write("页面加载的时间" + ts.TotalMilliseconds.ToString() + " 毫秒");
}
在.cs页面加入如下
DateTime dt;
protected void onPreInit(EventArgs e)
{
dt = DateTime.Now;
}
protected void onLoadComplete(EventArgs e)
{
TimeSpan ts = DateTime.Now - dt;
Response.Write("加载页面用时:" + ts.TotalMilliseconds);
}
s