How to convert SESSION Variable to Integer Type in C#
<p>I am using C#</p>

<p>I am trying to check whether my  login attempt is not more than 3, I mean with below condition</p>

<pre><code>if (((int)Session["LoginAttempt"]) != 3)
{
}
</code></pre>

<p>In Login failed condition I am doing increment like below:</p>

<pre><code>Session["LoginAttempt"] = ((int) Session["LoginAttempt"]) + 1;
</code></pre>

<p>But it is giving me error <strong>"Object reference not set to an instance of an object."</strong></p>

<p>Please suggest!</p>
