How to expire a web page immediately?
If user clicked Sign Out, the session is abandon and the browser diaplays the login screen. If the user clicks the browser Back button, the previous page should not come back. How does it work?
You need to set the page to not cache and check if the session exists on page load and redirect to the login page if it doesn't. Something like:
protected void Page_Load(object sender, EventArgs e)
{
SessionCheck();
Cache.SetCacheability(HttpCacheability.NoCache);
}
private void SessionCheck()
{
if (Session.Count == 0)
{
Response.Redirect("~/login.aspx");
}
}
Happy Programming
0 Comments:
Post a Comment
<< Home