문제

I am having problem with logout. After Logging out of the application also, when a user presses browser back button those secured pages are displaying.

And also the page load event is not firing for browser back button. I am using master page and content page.

My logout functionality is in master page.

    Session.Clear();
    Session.Abandon();
    Session.RemoveAll();
    Response.Redirect("~/Default.aspx");

Here my login page is Default.aspx.

도움이 되었습니까?

해결책

What you need to do is, just don't cache the page that you want to prevent user from access after you logs out:

Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();

다른 팁

I think you should not redirect to Default.aspx, in my way, I usually create a "middle page", this page will check sessions and and prevent go back previous page after logout.

The route could be like this: logout -> clear session page -> login page

So, from login page, if you click back button on browser, it would let you to clear session page and go back login area.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top