I am working on an application in which requirements are to calculate user total time spent on a page.
I have saved the page opening time in a session variable and get end time when session expires.
Session["StartTime"] = DateTime.Now;
protected void Session_End(object sender, EventArgs e)
{
Session["EndTime"] = DateTime.Now;
//Saves in db
}
Project requirements are to calculate only those time when user opens that page, when user minimizes current browser window that time must be excluded and also if user switches to some another tab in current browser page that time also not recorded.
How to detect that user is currently working on our project page in asp.net or in jquery?