count visits

A

Alberto

I'd like to count the number of visits of my page so I need find out an
event raised only when the app starts. I think this could be the
Session_OnStart but I don't know whats the object who send it.

Thank you.
 
A

Alvin Bruney

No that doesn't happen when the application starts. It happens when the
session starts. Put a counter variable in there and increment it. It will
need to be stateful, that is it needs to remember the value. You can find
the session_start event in the global.asax.x file.

regards
 
A

Alberto

Could you tell me how to find it?
Actually I see the Global.asax and the Global.asax.cs. In the Global.asax.cs
I can see this events:
acquireRequestState
AuthenticatedRequest
BeginRequest
Disposed
Elapsed
EndRequest
Error
PostRequestHandlerExecute
PreRequestHandlerExecute
PreSendRequestContent
PreSendRequestHeaders
ReleaseRequestState
ResolvedRequestCache
UpdateRequestCache

Thank you for your help
 
S

Scott M.

Look in Global.aspx for Session_Start(). In addition to storing your
counter in some statefull way, you'll also need to store it in some long
term way (for when you have to re-boot the server for whatever reason).
I've found that saving the hit count in an Application variable
(incrementing it in the Session_Start) and storing the latest value in a
counter file on the server works well. It does mean that in the
Application_Start event of Global.aspx, you need to read that file and set
the Application variable to the value in that file.
 

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

Staff online

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top