ASP.NET - clear session and redirect in html - Asked By msakt on 20-Jun-12 01:04 AM

<a href="Home.aspx">Return to the homepage</a>   if i click here session clear and redirct like below code call


 Session.Clear();
        Session["Logout"] = true;
       
        Response.Redirect("Home.aspx",false);
Jitendra Faye replied to msakt on 20-Jun-12 02:46 AM
Use this code-

 Session["UserName"]=null;
 Session.Abandon();

Response.Redirect("loginpage.aspx");
dipa ahuja replied to msakt on 20-Jun-12 04:33 AM
Write this code in the page from where you dont want to go back:
 
protected void Page_Load(object sender, EventArgs e)
{
  Session.Abandon();
  Session.Clear(); Response.Redirect("home.aspx");
  Page.RegisterClientScriptBlock("", "<script>if(history.length>=0)history.go(+1);</script>");
}