How to Automatically Redirects to LoginPage when Session Timeout

Hi friends,We already know sessions plays a very important role in the WebApplications.In this i would like to explain how to Redirect the page when sessions timeout.


just write the following code in the page from which page you would like to redirect

protected void Page_Load(object sender, EventArgs e)
    {
        string ToRedirectURL = "sessionpage.aspx";
        Response.AppendHeader("REFRESH", "20;URL=" + ToRedirectURL);
    }
After the 20 seconds the page will be redirects to session page as shown below in the figure




You can directly redirects to Loginpage or sessionPage...




That's it..If You Have any doubts please feel free to ask me i will always ready to help you
developercode
About the Author
Sayyad is a Software Engineer, Blogger and Founder of Developers Code from India.His articles mainly focus on .Net (Web and Windows based applications), Mobile Technologies (Android,IPhone,BlackBerry) and SEO.

Facebook Rss Twitter

Get Weekly News letter of Updates!