How to solve this Timeslot issue in C#
<p>I am trying to solve this business issue:</p>

<ul>
<li>A user gets 10 attempts to login every 5 minutes</li>
<li>If a user exceeds 10 attempts, I display a "You need to wait to
login" message</li>
<li>Once 5 minutes have elapsed, I need to reset the number of attempts
and let the user attempt 10 more times.</li>
</ul>

<p>I'd like to do this without using a <code>Timer</code> and I am storing most of this info in the <code>Session</code></p>

<pre><code>public class LoginExp
{
  public DateTime FirstAttempt;
  public int NumOfAttempts;
}
</code></pre>

<p>I store the <code>FirstAttempt</code> DateTime on Page Load.</p>

<p>On the Login button click:</p>

<ul>
<li>I increment <code>NumOfAttempts</code></li>
<li>I need to check if NumOfAttempts &lt; 10 <strong><em>within</em></strong> the same 5 minute time slot. I could get the number of minutes elapsed between <code>FirstAttempt</code> and <code>DateTime.Now</code> and do a mod of 5, but that won't tell me which timeslot this is in (In other words, a user may have attempted 3 times as of the 2nd minute and then comes back in the 7th minute to do an attempt again. The <code>mod</code> would give me the same value.</li>
</ul>

<p>Any thoughts on how I could do this?</p>
