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.

The article was published on January 11, 2019 @ 10:10 AM

Leave a Comment