Wrox Programmer Forums
|
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 15th, 2008, 09:34 PM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default Running up the ViewCount

I don't know if anyone here has ever caught this, but in TheBeerHouse it is possible for a user to purposefully "run up" the ViewCount of an article simply by refreshing the page over and over. Of course, this is because the IncrementViewCount method runs on every page load.

I have come up a few different solutions, all basically tied to tracking page views/refreshes (either in the ViewState, Session, or in a cookie). I wonder if anyone (besides me, that is) has ever tried to tackle this issue; and if so, if you came up with a different solution (maybe slicker than mine).

Thoughts, anyone?

__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
 
Old May 17th, 2008, 03:14 AM
Authorized User
 
Join Date: Jun 2006
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
Yeah, I know about this issue but couldn't find any work around. Also, if you post some comment and refresh the page over and over, you'll see that comment being added again & again!
I'm still unable to figure out whats going on!

Could you please share your solutions for view count in detail?
Thanks.
 
Old May 20th, 2008, 12:32 AM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

I will do that, but I'd like to see if anyone responds with a different solution first.

 
Old May 20th, 2008, 02:39 AM
Authorized User
 
Join Date: Jun 2006
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Till then, I'll try to come up with some solution !

 
Old May 20th, 2008, 03:28 PM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

Don't know if you ever noticed, but a lot of other applications exhibit this flaw (including this very forum)...

 
Old May 21st, 2008, 04:13 PM
Authorized User
 
Join Date: Jun 2006
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Default

No I never noticed that. You've got a developer eye ! :D

 
Old August 20th, 2009, 10:38 AM
Authorized User
 
Join Date: Aug 2009
Posts: 12
Thanks: 5
Thanked 0 Times in 0 Posts
Default

Lee, I have just come across this thread while searching posts. I haven't tried to tackle it. However, the simplest option to me would be to use cookies and session variables. Cookies would have an expiration which would allow you to set them last for a day. If the cookie is present then you set the session variable as soon as the user comes into the site. That way when you load the article you check for the session variable, if it exists you do nothing and if it doesn't you create the cookie, the session variable and increment the view count.

People that don't accept cookies you will be able to at least increment the view count once per session.

The other option is to register IP and article information per day. Even with dynamic IPs the user is bound to have the same assigned IP for a day. So you can create a table in the database tbh_ArticlesViews with three fields: ArticleID, ViewedIP, ViewedDate. If the record does not exist for the article, the ip and today you would increment the view count and create the record. You would need a stored procedure that runs every day to delete all records which date is less than today.

What do you think?





Similar Threads
Thread Thread Starter Forum Replies Last Post
Are Webparts running only with IE ? mrf ASP.NET 2.0 Basics 1 July 24th, 2010 08:45 AM
Rating &ViewCount do not increment tectrix BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 15 May 30th, 2007 06:46 AM
running my application RoniR ASP.NET 1.0 and 1.1 Professional 0 March 28th, 2007 07:46 AM
Running Sum semooth Access 2 July 21st, 2004 09:17 PM
Running ASP Valerie BOOK: Beginning ASP 3.0 2 April 7th, 2004 08:35 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.