How do I show the load time of the page.

Using MasterPages in ASP.NET 2.0, how can I get the page load time?  I am trying to get all of my pages to say something like:

Server response time: 1.366993 seconds.

or

Page load time: 1.366993 seconds.

Any ideas?  I have been playing with it for a while, and I don't think my results are accurate.

Thank you,

lee
mitztraykrayAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

raterusCommented:
Here's an accurate way to get the time, if that's what you want, just drop it in your page class

Private s_sendtime As Integer
Private e_sendtime As Integer
Private totaltime As Double

      Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
              s_sendtime = System.Environment.TickCount

      End Sub

      Protected Sub Page_SaveStateComplete(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.SaveStateComplete
             e_sendtime = System.Environment.TickCount
             totaltime = (e_sendtime - s_sendtime) / 1000

             response.write(totaltime.tostring)
      End Sub

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mitztraykrayAuthor Commented:
Thanks Raterus - I have implemeneted it, but I am not sure how to make the Page_SaveStateComplete subroutine fire.  Page_Init starts automatically when the page starts to load, but nothing after that calls Page_SaveStateComplete.

Thanks again,

Lee
mitztraykrayAuthor Commented:
I don't know if this matters or not, but I am using asp.net 2.0
raterusCommented:
you don't _have_ to do it in Page_SaveStateComplete, that just put's it a little later in the page lifecycle, perhaps try it in Page_PreRender, most of your page processing will take place before that fires (these events fire automatically)
mitztraykrayAuthor Commented:
I have no idea why my events aren't firing - I will open another question about this.

Thanks alot for your help!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.