The simplest way to do this is to record a certain amount of information after the user polls, and to detect the presence of that particular information each time it polls. The method of implementation I think of 3 kinds, specific as follows:
1, with page.session;
private void Saveinsession ()
{
if (page.session["OK"]==null)
{
Vote ();
page.session["OK"]=1;
}
Else
{
Novote ();
}
}
2, with Request.Cookies;
private void Saveincookie ()
{
if (request.cookies["OK"]==null)
{
Vote ();
HttpCookie cookie = new HttpCookie ("OK");
Cookies. Values.add ("Visit", "1");
Cookies. Expires = DateTime.Now.AddYears (1);
Response.appendcookie (cookie);
}
Else
{
Novote ();
}
}
3, with Page.cache;
private void Saveincache ()
{
if (page.cache["OK"]==null)
{
Vote ();
page.cache["OK"]=1;
}
Else
{
Novote ();
}
}
To make a complex point can also record the user's IP, write to the database, before voting to see if the database has a voting record, this method is more complex, but can avoid the previous several users to turn off the page and enter the issue of voting.
If there is any better solution, please.