How to find client information in asp.net

I have a web page and people come there to vote. but I want everyone to send just one vote! please help me with the c # code.

+2


source to share


5 answers


There are several different approaches you can take.

One approach should be to register each IP address. The problem is that there are a lot of people behind the routers. If you prevent users from voting by ip address, you can block people who have not yet voted.



A second approach is to require the user to log in. This is the most reliable way to prevent users from voting more than once. It is also the most active part. You can reduce the workload by using the ASP.NET Membership Provider.

A third approach is to set a cookie on the user's computer. They can easily delete a cookie, but most users don't know what they are and don't care.

+2


source


It's tricky and I'm sure you'll have to compromise in some way.

  • Check the IP address in how to find client information in asp.net and HTTP_FORWARDED, the problem is that any IP address is easily spoofed and two people can use the same computer and / or have a dynamic IP: s

  • Send a confirmation email

  • User must register in your system

  • Require OpenId



I would go to number 4

+2


source


Get an IP address using this operator.

HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];

      

When people vote, store the IP address in the database and check the 2nd time they come

OR

You can store some information in a client cookie and check for a second time

+1


source


Get the MAC address from the remote computer and track it.

want to get the MAC address of the remote PC

However, this would be more complicated in C # as I am pretty sure you cannot do it with .NET since you will need to use ManagementObjects which probably won't work.

However, if you are doing this from asp.net, you can do the Java thing by inserting it into an asp.net page and calling it as needed.

0


source


If you want a simple and reliable solution, just use the cookie mechanism .

You need to try reading Cookie first: http://msdn.microsoft.com/en-us/library/aa287533%28VS.71%29.aspx

HttpCookie myCookie = new HttpCookie("MyTestCookie");
myCookie = Request.Cookies["MyTestCookie"];

if (myCookie != null)
  //User has already voted.
else
  //User can vote.

      

If the cookie doesn't exist you allow voting, after voting you just write a cookie in response: http://msdn.microsoft.com/en-us/library/aa287547%28VS.71%29.aspx .

HttpCookie myCookie = new HttpCookie("MyTestCookie");
Response.Cookies.Add(myCookie);

      

0


source







All Articles