How can I count page views so that when I go and refresh the page the counter doesn't consider it as new view?
+3
A:
1-declare a session for each user
2- declare application variable for the page visited
and after you start the session
check if page visited like the following:
on the user login page or homepage:
Session["pageVisited"] = false;
when user visit the page write in the code behind:
if(SESSION["pageVisited"] == false)
{
APPLICATION["Page1Visited"] = Convert.Toint32(APPLICATION["Page1Visited"]) + 1;
SESSION["pageVisited"] = true;
}
peacmaker
2009-12-29 08:06:24
However, if the user visits the page again it wont increase the counter, and it doesnt count as a refresh? so you will only be counting unique views per session.
Madi D.
2009-12-29 08:21:00
Agreed - page views will still be counted on refresh, however you can use page visits to determine unique visitors
Mike Robinson
2009-12-29 16:39:19