Calculating Page Load times?

G

Guest

Hey all,
I just started working with .net 2.0 master pages. What is the best way to
calculate page load times using master pages and user controls? I'm not sure
the order of execution and where to put the timestamping code?
Thanks in advance
Andy
 
P

PeterKellner

Hey all,
I just started working with .net 2.0 master pages. What is the best way to
calculate page load times using master pages and user controls? I'm not sure
the order of execution and where to put the timestamping code?
Thanks in advance
Andy

Here is what I've done. (I put this code on each page)

private DateTime startTime;

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


protected void Page_UnLoad(object sender, EventArgs e)
{
if (utils.Constants.logPageHits)
{
string urlReferrer = string.Empty;
string userAgent = string.Empty;
string userHostName = string.Empty;
string userHostAddress = string.Empty;
string userPrimaryLanguage = string.Empty;
urlReferrer = HttpContext.Current.Request.UrlReferrer ==
null
? string.Empty
:
HttpContext.Current.Request.UrlReferrer.ToString();
userAgent = HttpContext.Current.Request.UserAgent == null
? string.Empty
:
HttpContext.Current.Request.UserAgent.ToString();
userHostName = HttpContext.Current.Request.UserHostName ==
null
? string.Empty
:
HttpContext.Current.Request.UserHostName.ToString();
userHostAddress =
HttpContext.Current.Request.UserHostAddress == null
? string.Empty
:
HttpContext.Current.Request.UserHostAddress.ToString();
userPrimaryLanguage =
HttpContext.Current.Request.UserLanguages == null
? string.Empty
:
HttpContext.Current.Request.UserLanguages[0].ToString();

// -1 because user never logged in here and we don't have
ref integrity on page log file
utils.LogPageLoadTime(startTime, "Default.aspx", -1,
urlReferrer, userAgent,
userHostName, userHostAddress, userPrimaryLanguage);
}
}
Peter Kellner
http://peterkellner.net
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top