"If at first you don't succeed; call it version 1.0" :-Unknown

Pages

Saturday, May 15, 2010

Detecting Session Timeout and Redirect to Login Page in ASP.NET

Hi ,
V can do this by calling the Page_Init() function.. I hope everybody have an idea abt this function.v are checking our session value on this function.

Code

    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Page_Init(object sender, EventArgs e)
    {
        CheckSession();
    }
    private void CheckSession()
    {
        if (Session["SessionID"] == null)
        {
            Response.Redirect("Login.aspx"); // This means session haves no value
        }
    }
I hope this will help you

Have a nice day... 'N happy Coding :)

This Is UsMillenniumThe Hits--Chapter One 

No comments: