English 中文(简体)
MVC ASP的Hit对手。 NET网站
原标题:Hit counter for MVC ASP.NET website

How to create a hit counter(visitor counter) for each page in MVC website? And store information in MS SQL Database. The same as stackoverflow using on each page.

请举一个例子。 感谢u

问题回答

在你的主页上,插入一个功能,即标明网页名称或你想要的任何其他细节。 页: 1

我能够利用各种会议变量,在伙伴关系中提供ql服务器db。 NET MVC。

注:我使用了会议变量,而不是储存客户IP地址。 节省所有客户地址后,将超出你的数据库。 这与Stackoverflow网页相类似,认为每个问题都有产权。

这就是我的工作方式。

Whenever a user opens a particular web page in your website, the counter increments and the updated count will be updated in sql server database(it could be anyother database) tables. If the same user visits the same webpage again within the same session, the counter will not be incrmented. That means if user refreshes a web page multiple times with in the same session, the counter will not be incremented, as it is a single visit by that user. If the same visitor closes his session(say he closes the browser) and reopens the same web page the counter will be incremented considering it as a separate visit. Here are the steps I followed to implement it.

Have a method which will be automatically called before every Action method. Inside this method, initiate a session if it is not done already and check if the user has visited this page already. Now, update the counter variable accordingly and save the count to db if required. Here is the complete procedure I have followed. Hope it helps.

资料来源:





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签