Lock out users after three unsuccessful attempts without using a database
<p>I want to lock out my users after three unsuccessfull attempts without using a database.</p>

<p>I was trying:</p>

<pre><code>public int loginAttempts()
{
    if (!(ViewData["loginAttempts"] == null))
    {
        ViewData["loginAttempts"] = int.Parse(ViewData["loginAttempts"].ToString()) + 1;
        return int.Parse(ViewData["loginAttempts"].ToString());
    }          
    else
    {
        ViewData["loginAttempts"] = 1;
        return 1;
    }
}
</code></pre>

<p>But it always returns 1. What modifications do I need to make?</p>
