asp.net handling Back button event after Logout

In the logout link button click event I have cleared the session variables. I am checking these session variables for null values at each page’s load event. If it has the null value redirecting them to the login page.
But the problem is whenever I click the browser back button, the page_load event won’t get called. For that I have cleared the the browser cache history.
Please help me someone where I am missing…

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

You will need to make sure the pages behind the login (those that can only be accessed after login) are not cached in the browser:

Page.Response.Cache.SetCacheability(HttpCacheability.NoCache);

If using forms authentication, you will also need to abandon the session and logout:

Session.Abandon();
FormsAuthentication.SignOut();

See this, this and this.

Method 2

Try this code, hope it works

Response.Cache.SetCacheability(HttpCacheability.NoCache);

Response.Cache.SetExpires(DateTime.UtcNow.AddHours(-1));

Response.Cache.SetNoStore();


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x