C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




need per day visitors count


Posted Date: 16 Oct 2008      Total Responses: 3

Posted By: SATHIYENTHIRA BOOPATHY.H       Member Level: Bronze     Points: 1


Hi,

I want to show visitors count for the website per day upto last moment.How to do this?

Pls give me the best solution.


Thanks & Regards

H.Sathiyenthira Boopathy.




Responses

Author: Meetu Choudhary    16 Oct 2008Member Level: GoldRating:     Points: 3
for this you have to create an application variable which will be initialized with zero at the start of day and when a new session starts increment it by one and any moment when you read this you will get the total no of visits for the site at that particular moment for the day

hope it helps you

==
Thanks and Regards
Meetu Choudhary



Author: Athira Appukuttan    16 Oct 2008Member Level: DiamondRating:     Points: -20
Try like this Global.asax:

Sub Application_OnStart
'initialize variable
Application("visitors_online") = 0
End Sub
Sub Application_OnEnd

End Sub

Sub Session_OnStart
Session.Timeout = 20 '20 minute timeout
Application.Lock
Application("visitors_online") = Application("visitors_online") + 1
Application.Unlock
End Sub
Sub Session_OnEnd
Application.Lock
Application("visitors_online") = Application("visitors_online") - 1
Application.Unlock
End Sub



On line users: <%=Application("visitors_online")%>






Author: Nagarajan    16 Oct 2008Member Level: GoldRating:     Points: 2
A small change to appukuttan's code,

As you need dially visit count, the application variable has to be reset at the end of the day, else when you see the count next day morning, it get appended to previous day count.

Sub Application_OnStart
'initialize variable
Application("visitors_online") = 0
Application("currentDate") = Datetime.Today
End Sub
Sub Application_OnEnd

End Sub

Sub Session_OnStart
Session.Timeout = 20 '20 minute timeout
Application.Lock
if Application("currentDate") <> DateTime.Today
Application("visitors_online") = 0;
Application("currentDate") = DateTime.Today
end if
Application("visitors_online") = Application("visitors_online") + 1
Application.Unlock
End Sub

Sub Session_OnEnd
Application.Lock
Application("visitors_online") = Application("visitors_online") - 1
Application.Unlock
End Sub

Just added a Date value to Application to kepp track of the end of day.

Hope this helps
Happy Coder.


Post Reply
You must Sign In to post a response.
Next : CSS for any browser
Previous : PreRender Event
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

it outsourcing

Contact Us    Privacy Policy    Terms Of Use