简体   繁体   English

确定Asp.net MVC中特定页面的视图计数

[英]Determine the view count for specific page in Asp.net MVC

Do anyone knows 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. 就像在StackOverflow中一样,在问题列表中,您会看到View count,它描述了查看问题的次数。

I would like to know how to do this in asp.net mvc. 我想知道如何在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, eg 然后,您可以向域对象添加属性,该属性可以由数据访问层以正常方式填充,例如

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

You can then display this in your page. 然后,您可以在页面中显示此内容。

如果使用得当, Google Analytics是一个非常好的工具。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM