Thursday 4 April 2013

Redirection To Login page After Session Time Out In Asp.Net


Redirection To Login page After Session Time Out In Asp.Net
So on the button click add the below code. in this code i am assigning value to session .

protected void btnGenerate_Click(object sender, EventArgs e)
{
Session["SessionID"]=txtSession.Text;
}

Now on second button add the below code.
protected void btnCheck_Click(object sender, EventArgs e)
{
if (Session["SessionID"] != null)
{
txtSession.Text = Session["SessionID"].ToString();
}
else
{
Response.Redirect("Default2.aspx");
}
}

In above code i have checked if session value is null then redirect to the second page . In case of login page you can check the session value on page load.

No comments:

Post a Comment