Actually i would like to stop user from back to the previous page once logout. For this situation, my plan is to write down a cookie once logout (check the “SetLogoutCookie” function), and read the cookie once page load for every online page except login.aspx (check the “RedirectToLoginPage” function). If the data in cookie means that logout then redirect current page to login.aspx. as an example, I actually have provided the subsequent code for your reference. Hope it’s useful to you.

ASP.NET Code for Default page:

C# Code for Default page:

ASP.NET Code for Login page:

C# Code for Login page:

Code for Web Config:

P.S. You can put the JavaScript code to a separate js file, and include the file in each page.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.