Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET SQL-Server
Hello Friends,
Have a good day all of you !!!!!
 
Count Menu clicks and save Number of clicks in SqlServer database 2005.
=========================================================
 
I have Created a WEB Application in Asp.net C#, SqlServer 2005.
 
In this Web Appl I have Menus Such as Home,About us, View Result, View Toppers, Contact us....etc links in menus.
 
When User clicks this links it must count and store in SqlServer 2005 database.
 
So, that I can Know how many users are viewing my web application.
 

Please help me brothers.
 

Thanks a lot
Posted 16-Oct-12 21:10pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Brother you don't have to do like that.
 
you have Global.asax file in your web project.
void Application_Start(object sender, EventArgs e)     
{
   // Code that runs on application startup.        
   Application["Visitors"] = 0;
}
 
void Application_End(object sender, EventArgs e) 
{
        //  Code that runs on application shutdown
}
void Application_Error(object sender, EventArgs e) 
{ 
      // Code that runs when an unhandled error occurs  
}
void Session_Start(object sender, EventArgs e) 
 {
      // Code that runs when a new session is started.
       Application.Lock();
       Application["Visitors"] = Convert.ToInt32(Application["Visitors"])+1;
       Application.UnLock();
}
void Session_End(object sender, EventArgs e) 
{} 
 
Whenever session_start event occurs you need to increase your visitor value by one & you can insert that value in the database.
Hope it helps
  Permalink  
v2
Comments
Milind Thakkar at 17-Oct-12 2:48am
   
@Sushil: I think this will count unique visitor. What OP wants I think is number of pages visited.
Sushil Mate at 17-Oct-12 2:55am
   
@Milind: see his last line "So, that I can Know how many users are viewing my web application." so he could be want unique visitors... what he ll do by knowing the number of pages visited by visitors :)
 
Nevertheless its confusing one. let the OP clarify on this one
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

If you want to find unique visitors to your web-site, follow what Sushil has suggested above.
 
If you need to find total pages visited or number of pages visited, the simplest thing to do is to go for Google analytics which is free. You need to host site so that it accessible to Google Analytics.
 
Else, if you want to develop your own method, I would suggest you create a base page class ederived from system.page and then derive all your pages from this your own base page class.
 
In this custom base class, you advance total page count and user page count and/or store in database against the user.
 
Hope that helps. If it does, mark the answer as solution and/or upvote.
 
Thanks
Milind
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 295
1 DamithSL 265
2 CPallini 235
3 Maciej Los 190
4 George Jonsson 170
0 OriginalGriff 5,415
1 DamithSL 4,422
2 Maciej Los 3,820
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,911


Advertise | Privacy | Mobile
Web03 | 2.8.141216.1 | Last Updated 17 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100