Where do i start the stopwatch and where should it stop?
The logical place for the stopwatch to start should be the controller action method, yes, no?
But where should the stop the clock? I would like to think that it goes at the end of the master page? It doesnt make sense to stop the watch at the end of the controller action method because there will additional process which happens in the View to render the page.
Any thoughts?
EDIT: I intend to use the elapsed time within a master page so i can get the time for any webpage.
Darin: Thanks for the code sample. But the sample does not work as i expected. I planned to use the elaspsed time in a master page so it can be written to every page.
So i think the Master page would've already loaded by the time EndRequest get executed?
In my EndRequest i set:
Context.Items["PageCreationTime"] = watch.ElapsedMilliseconds.ToString();
Then i my masterpage iam unable to get reference:
<%= HttpContext.Current.Items["PageCreationTime"].ToString()%>