views:

38

answers:

2

I have a database generated page which shows lots of links.

This page consists of 3 colums. In the first column, it gets the links from the database. In the second column it generated + links, and in the last column, it generated a - link

So basically, each row generated consists of a url link, a + link and a - link.

  • When the user clicks on the link, it goes to the appropriate page
  • when the user clicks on the + next to any given row, the database is updated to reflect that the user likes that link
  • If the user clicks - next to any given row, the database is updated to reflect that the user does not like that link.

What is the proper way to recreate this page to stop web bots from emulating link clicks? Specifically, what do I need to do to the + and - links to stop bots from clicking them?

+1  A: 

Use forms and POST instead of links and GET.

GET is supposed to be used only for Safe / Idempotent operations.

David Dorward
+1 whenever you submit data, you should use forms and POST. A GET request is not supposed to change anything.
AHM
So basically use input type submit to replace the + and - links?
oshirowanen
Yes. <input type="submit" name="vote" value="+"> should do the job. You can style away the borders and background.
David Dorward
How would I get each submit button to do a slightly different thing? For example, if the + submit button is clicked on row 1, add 1 to a column in the database which is related to row one, if + is clicked for row 2, do the same as above but for row 2, if - is clicked on row 10, minus a number from the database for row 10 in the database.
oshirowanen
Check the value. (And include a hidden input if you want to pass along an id of something)
David Dorward
Lets say I have 10 rows, 10 + buttons, 10 - buttons, and 10 hidden input tags. If I click + on the 8th row, how do I send the 8th hidden row data back to the server? Or will I have to send it all back as normal, then process it at the server level to figure out which row was clicked on?
oshirowanen
<input type="hidden" name="row" value="8"><input type="submit" name="vote" value="+"><input type="submit" name="vote" value="-">
David Dorward
I don't understand how this is working? If I have 10 submit buttons and 10 hidden fields, if I click on any of the 10 submit buttons, will it not send all hidden data back to the server?
oshirowanen
You have one form per row.
David Dorward
I thought it was not possible to use multiple forms in asp.net?
oshirowanen
Ya? What? Microsoft can't have written something that crap, surely? Multiple forms in a page are a very basic and fundamental feature of how the web works.
David Dorward
As far as I know, in asp.net you can only have 1 form on the page which has a runat="server" atribute... Maybe I'm doing something wrong?
oshirowanen
A: 

You could define a Robots.txt file in the rootfolder, or subfolders of your application, telling webcrawlers not to read certain (or all) pages. More info on that.

Joachim VR
I can't use this as a solution for this, because I do want web bots to visit this page, and I do want them to check out the links, but not the + and - links.
oshirowanen
Then just use linkbuttons instead. Bots usually won't execute the javascript attached to it.
Joachim VR