I have a Catcha value( Security Code ) that is store in Session on PageLoad and that is going to be used when user clicks the search button. If the User is IDLE for more than 20 Min the value of Session is get expired. And when user clicks on Search Button. It Throws error " Object Reference Not Set To an Instance of an Object".
On PageLoad:
if (!IsPostBack)
{
Session["CaptchaImageText"] = new RandomGen().GenerateRandomCode();
}
On SearchButtonClick event:
if (SecurityCodeTextBox.Text.Trim() == Session["Captcha"].ToString())
{
return true;
}
else
{
return false;
}
Here i get error "Object Reference Not Set To an Instance of an Object". i have also checked wheather the Session["Captcha"]!= null. But still it shows the same error.
How to Redirect or show a message that "Session Timeout !Visit again" and close the Browser.
Thanks in Advance!