简体   繁体   中英

problem of back history not being clear after logout in asp.net

protected void Page_Load(object sender, EventArgs e){
    Session.Abandon();
    FormsAuthentication.SignOut();

    Page.Response.Cache.SetCacheability(HttpCacheability.NoCache);
    Response.Redirect("~/Admin/adminLogin.aspx");

}

I m not using any master page.so i have make one logout page and write code in it as above. But after logout it still goes back to previous page.

You can put this code in the page load

protected void Page_Load(object sender, EventArgs e)
{
    if (!HttpContext.Current.User.Identity.IsAuthenticated)
    {
        Response.Redirect("Login.aspx");
    }
}

I'm not sure this is the answer you are looking for exactly. What I do is I put the authentication code in a custom HTTPModule, that way it is executed before all page requests and you simply check status and do your redirection from there.

Then you simply put an exception for your login pages and resource locations. This has the advantage of being able to secure all files on the server with the right settings.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM