Determine the number of views for a particular page in Asp.net MVC

Does anyone know how to make a view counter for a specific page. As in StackOverflow, in the list of questions you will see a viewing counter that describes how many times the question has been viewed.

I would like to know how to do this in asp.net mvc. I already have an idea, but I'm not sure if it’s right.

I need expert advice ... thanks

+3
source share
2 answers

A common way to do this is to record the number of queries requested in the database. Then you can add a property to the domain object, which can be populated in the usual way with a data access layer, for example.

public class Question
{
    public int HitCount { get; set; }
}

.

+2
+1

Source: https://habr.com/ru/post/1733207/


All Articles