0

I am working on the bus ticket reservation system. I have developed all the login scenarios for all actors on role base access. All the actors login via login page and login page redirects them to their permitted home pages. Now the user session has get started and after completing the required tasks, presses logout button and this logout button does:

    Session.Abandon();
    Response.Redirect("default.aspx");

After that, the user is on default login page but when the user presses the browser back button the same home page remains showing in the window until he or she refresh the home page manually. home page code is:

if(Session["user"] != null)
{
   //welcome user
}
else 
{
    Response.Redirect("../Default.aspx");
}

I want to refresh the home page on pressing browser back button that the user no longer see the page after the logout. how we can do this work in c# .net?

2 Answers2

0

You can do it in Javascript something like this

<body onbeforeunload=”HandleBackFunctionality()”>
function HandleBackFunctionality()
{
    if(window.event)//For IE
   {
        if(window.event.clientX < 40 && window.event.clientY < 0)
        {
            location.reload();
        }
        else
        {
            alert("Browser refresh button is clicked...");
        }
    }
    else//For other browsers
    {
        if(event.currentTarget.performance.navigation.type == 1)
        {
             alert("Browser refresh button is clicked...");
        }
        if(event.currentTarget.performance.navigation.type == 2)
        {
             location.reload();
        }
    }
}
Shrivallabh
  • 2,863
  • 2
  • 27
  • 47
0

you want to disable caching on the "secure" pages so when someone logs out and click the back button (or history) they will not see the browser cached version of it...

See how to do that in this post: How to handle form submission ASP.NET MVC Back button?

Community
  • 1
  • 1
Yovav
  • 2,557
  • 2
  • 32
  • 53