.net取得页面加载时间

public DateTime dt;
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected override void OnPreInit(EventArgs e)
        {
             dt = DateTime.Now;
            base.OnPreInit(e);
        }

        protected override void OnLoadComplete(EventArgs e)
        {
            base.OnLoadComplete(e);
            TimeSpan ts = DateTime.Now - dt;
            Response.Write("加载页面用时:" + ts.TotalSeconds);
        }

posted @ 2012-03-22 10:45  为乐而来  阅读(312)  评论(0编辑  收藏  举报