好记性不如烂笔头。

asp.net 精确统计页面加载时间

在Glogal.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("The request takes " + ts.TotalMilliseconds.ToString() + " milliseconds");
        }