Click here to Skip to main content
15,034,986 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi,
After login from Defaul.aspx(login.aspx) page, my website goes to Default2.aspx.

In my Master page i have a Log Out Image button. When i click Log Out, i have redirected to Default4.aspx page where i have cleared session and finally redirected to Default.aspx(Login.apsx) page like below

C#
protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["UserID"] != null)
        {
            Session.Clear();
            Response.Redirect("Default.aspx");
        }
    }



Also in Master page i have the following code at page load:

C#
protected void Page_Load(object sender, EventArgs e)
 {
  
  if (Session["UserID"] != null)
   {
          
   }
  else
  {
    Response.Redirect("Default.aspx");
  }
}


Now when i click Back button of browser,it can goes to Defaul2.aspx.

I dont want website to redirected to Default2.aspx, after log out is clicked rather user has to enter user name and password.

How can i achieve this.

Thanks
Posted

1 solution

You need to turn off caching. I suggest you read this[^] article. The short version is:

Response.Cache.SetCacheability(HttpCacheability.NoCache)
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900