Thursday, April 28, 2011

ASP.NET: Automatic redirect to login page after session expires

If you want to automatically redirect to a page as the session expires, this is how you can do it:

Just check the session's existance. If it is no more in the server , then redirect to the desired page. The code snippet is as follows:

if (Session["session_name"] == null)
{
Response.Redirect("the_page_you_want_to_redirect_to.aspx");
}

No comments:

Post a Comment