页面生成时间 [英] Page generation time

查看:80
本文介绍了页面生成时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在asp.net,C#中的服务器端生成页面加载时间.??????
我尝试使用以下方法,但我不想使用此方法....

how to generate page load time at server side in asp.net, C#.??????
I have tried with the below method but i don''t want to use this....

private int startTime;

protected void Page_Init(object sender, EventArgs e)
{
    startTime = Environment.TickCount;
}





protected void Page_PreRender(object sender, EventArgs e)
{
    int endTime = Environment.TickCount;
    double executionTime = (double)(endTime - startTime) / 1000.0;

    lblLabel.Text = "Page Execution time is " + executionTime + " seconds.";
}

推荐答案

输入
int startCounter= DateTime.Now.TimeOfDay.TotalSeconds;

作为page_load中的第一条语句,以便在加载此应用程序后获取TotalSeconds

并在页面加载的末尾添加

as a first statement in the page_load in order to to get the TotalSeconds when this application has been loaded

and at the end of the page load add

int endCounter = DateTime.Now.TimeOfDay.TotalSeconds;



现在添加



now add

int totalSeconds = endCounter - startCounter;

//这将获得运行此事件所需的时间.

//which will get the time needed to run this event.

Response.Write(totalSeconds);



另请参阅此链接
http://msdn.microsoft.com/en-us/library/0x5wc973 (v = vs.85).aspx [



Also Refer This Link
http://msdn.microsoft.com/en-us/library/0x5wc973(v=vs.85).aspx[^]

Hope This Will Help You


这篇关于页面生成时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆