tags:

views:

147

answers:

2

Hi,

Do anyone knows how to do the View count for a specific page.

Like in youtube, when you click a video, the number of view count will increment. But if you already viewed the video before it will not increment.

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: 

I would simply store a permanent cookie on the user... Though, that would be reset when the user deletes it.

Stephane
thanks for the inputs. but i might not use a cookie after all bec. of browser option if cookies disabled. thanks
happy
A: 

You would probably need to store the total view count in a db and as serbrech said use a cookie to determine if the user has been to the page before and if not increment the view count.

Simon G
thanks for the inputs. but i might not use a cookie after all bec. of browser option if cookies disabled. thanks
happy
Another option is to store the users ip address (or if a users is required to login to view the page the user id) against a record in the db and check whether the uses has been to the page before incrementing the value. But this will be another call to the db, you have to consider if the view page counter has to be accurate compared to the cost of checking against a db every time a page has been viewed or just incrementing the value if a cookie doesn't exist.
Simon G