count visits

  • Thread starter Thread starter Alberto
  • Start date Start date
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.
 
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
 
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
 
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.
 
Back
Top