When a session variable reaches timeout a NullReferenceException
is thrown. I know you can change how long it takes for the session variable to timeout. I'm trying to remove all possible ways for anything to crash. Is there any reason why the exception is not being caught here?
protected void Page_Load(object sender, EventArgs e)
{
try
{
// Get session variables.
String strParticipantID = Session["ParticipantID"].ToString();
}
catch (NullReferenceException)
{
Response.Redirect("Login.aspx");
}
}