Page Counter...

S

Samir Patel

Hi,
I am developing C#.net web base application.
I want to know how I can page count a same page. I want to this type.

1) When a new user open page he/she see the number of pages open same time
and total how many time this page open.
Suppose 10 user open search.aspx every user see this page count=10;
And also see total open=12,000 (it is total time's opened this page)

2) If user refers page page count not increase.

Bye.

Samir.(Software Developer, INDIA)
 
M

msreekm

Hi,

Is it the count of number of pages opened now and count of number of
times the current page was ever opened??

-Sree
 
D

Dalvir Singh

Hi Samir,

Try this code. You have to convert this to proper syntex.

In Global.asax:
On Session_Start set Application("Count") = Application("Count") + 1
On Session_End set Application("Count") = Application("Count") - 1


On page:
To display total online users
Show Application("Count")

To manage unique visits:

If Session("ExistingVisitor") = "" then
Session("ExistingVisitor") = "True"

TotalUsersVisitTillDate = ReadFromDatabase/TextFile
TotalUsersVisitTillDate = TotalUsersVisitTillDate +1
WriteToDatabase/TextFile TotalUsersVisitTillDate

End if
 
G

Greg Burns

Wouldn't/shouldn't you have to use Application.Lock in this situation?

Application.Lock
Application("Count") += 1
Applicaiton.Unlock

Greg
 
D

Dalvir Singh

Hi Dave,

Application variable is used to store current online users at any time. If
application is restarted, there will be no online user. So combination of
sessin and application will work fine here and will use least resources.

For saving the total visits, db or text file should be used.


Dalvir Singh
 
S

Scott M.

For total number of visits:

In Session_Start:

Increase an application variable by 1
Write that number to a log file

In Application_Start:

Check for the existence of the log file
If it exists, set the application variable to the value in the log file
If not, create a log file with zero as its initial value

For number of times page has been opened:

Create a shared (static in C#) property for this page class that holds the
count
Increase the number by 1 in the page's constructor
This value will hold the total number of times this page has been instanced
and is callable from any instance.
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,019
Latest member
RoxannaSta

Latest Threads

Top