Do anyone know开发者_运维技巧s how to do the View count for a specific page. Like in StackOverflow, in the question list you would see the View count which describes how many times the question was viewed.
I would like to know how to do this in asp.net mvc. I already have an idea but im not sure if right.
I need an expert advice... thanks
A common way to do this is to log the number of times a page is requested in a database. You can then add a property to your domain object which can be populated in the normal manner by your data access layer, e.g.
public class Question
{
public int HitCount { get; set; }
}
You can then display this in your page.
Google Analytics is a VERY good tool, when used properly.
精彩评论