views:

137

answers:

2

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
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.
+4  A: 

Use google analytics ;)

Ofri Raviv
Agreed - page views will still be counted on refresh, however you can use page visits to determine unique visitors
Mike Robinson