Hello i am creating a poll website to vote for some projects but i want to prevent voting more than only one time and i want to control it by client IP .. do you have any idea?? thnks , regards !!
how to allow to vote only once by controlling client IP in my poll website with c#?
Collapse
X
-
If you can capture the client IP as they click to vote, then in your code logic follow these steps:- check the data table for the client IP
- if it exists return a message that they already voted
- else insert the client IP into the data table and return an acknowledgement message
-
If your website is behind a proxy server, the request.serverv ariables("REMOT E_HOST") might always return its IP (proxy server), in this case, check this link:
I have the following code: string ip = Request.ServerVariables["REMOTE_ADDR"]; Which, in the test environment does return the user IP addrress, but when we deploy the website to production, this
For future reference, here is a list of the ASP ServerVariables Collection:
Comment
-
If you can capture the client IP as they click to vote, then in your code logic follow these steps:
1. check the data table for the client IP
2. if it exists return a message that they already voted
3. else insert the client IP into the data table and return an acknowledgement message
With server variables; in your case request.serverv ariables("REMOT E_ADDR")Comment
-
"What will happen if the ISP of the client allocates dynamic IP for the client whenever client connects to the internet?"
You are right vijay6 it is a good concern but one would have to turn off and on their modem and hope to get a different IP just to vote again. My ISP allocates dynamic IP addresses as well, and I do not know if it is the same for most ISP but in over 10 years I think my IP address changed three or four times...but then again my modem is always on.
So you brought a valid point, and there are other methods to consider:
One could to try to capture the MAC Address of the user, but that can be falsified as well.
Cookies is another way, but cookies can be deleted.
Getting voters to register and login before voting, but again one can register multiple times.
There is a lot to consider but for the sake of simplicity I think this is good enough for the purpose of a poll (unless of course you are electing a new president :)
There is probably a better way to do this that someone knows out there but that was my two cents
P:oD
p.s.
cool name "vijay6", you should get a proper avatarComment
-
Hey pod, whatever method we use we can't stop fraud vote for this scenario but we can reduce it. By capturing few more informations. Like what you said by capturing IP address, Mac address and Login & Vote, we can reduce it.
you should get a proper avatarComment
Comment