Logout or signout problem in asp.net c# using Master page and windows authentication

10,695

Solution 1

Easiest way to resolve this problem is to disable the cache of the page.

This should help you out.

Solution 2

Login Page

protected void Page_Load(object sender, EventArgs e)
{
    Session["imp"] = "0";            
}

protected void LinkButton1_Click(object sender, EventArgs e)
{
    Session["imp"] = "1";
    Response.Redirect("AdminHome.aspx");
}

Log Out Page

protected void Page_Load(object sender, EventArgs e)
{
    Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
    Response.Cache.SetCacheability(HttpCacheability.NoCache);
    Response.Cache.SetNoStore();
    if (Session["imp"].ToString() == "1")
    { }
    else
    {
        Response.Redirect("HomePage.aspx");
    }  
}

protected void LinkButton1_Click(object sender, EventArgs e)
{
    Session["imp"] = "0";
    Session.Abandon();
    Response.Clear();
    Response.Redirect("HomePage.aspx");
}
Share:
10,695
Admin
Author by

Admin

Updated on June 13, 2022

Comments

  • Admin
    Admin almost 2 years

    I am new in asp.net, My problem is facing logout problem in myappication using master page and window authentication. After i signout from my application if i use browser back button it again goes back to signed page after that i click any control then only it is goes back to the logout stage but i want to dont show the logged page unnessarily.

    i am using href,document.location.replace(page),response.write("mypage.aspx") these technique for naviagation purpose and i am using session in all pages.

    Note: I am using login and logout in master page top itself...so if i check the session for null redirect to home page which is also a content page then i am not getting the home page it self to login because infinite looping occurs...

    when i am searching i got some coding to clear the cache but i a am facing problem that is after i logged and navigate to some of pages then i click browser backbutton without signout it is showing page is expired Click refresh to get the data back....

    Finally, I need solution like google signout i.e: after signout from google page then if we use back it shows only the home page. and please tell which event is fired while clicking the browser backbutton if yes how to validate session and redirect to logout page.

    Please help me i am facing these problem in one-week....

    Thanks in advance to everyone..