Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HitCounter in MVC

Tags:

asp.net-mvc

I'm trying to build a hit counter for different parts of the website in ASP.NET MVC - any idea where the best place to do this would be, or a good way to do it? We're wanting to track how many hits individual parts of the website get.

like image 995
Ciel Avatar asked Jan 18 '10 14:01

Ciel


People also ask

How can show visitor count in asp net?

You'll need some kind of data store which can persist your data when you application is not running. Here are some choices: File (XML, JSON, plain text, etc.): sample xml code for visitors counter. Database (SQL Server, SQLite, etc.): sample database code for hit counter.


2 Answers

Depending on the granularity you want, here are some options:

  • You can implement an ActionFilterAttribute that records the hit to some store.
  • You can derive from DefaultControllerFactory and record the hit for each requested Controller.
like image 55
Mark Seemann Avatar answered Nov 15 '22 08:11

Mark Seemann


If you are looking for website stats, I would use Google Analytics.

like image 42
mlsteeves Avatar answered Nov 15 '22 10:11

mlsteeves