Results 1 to 2 of 2

Thread: How to disable user's browser back-button after they logged-out?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2003
    Posts
    782

    How to disable user's browser back-button after they logged-out?

    Hi,

    I use ASP MVC Net Core 3.1, I am expecting to disable the browser back button after the user logged out, my Logout code is below, it goes there but the user's back button still functioning, how to disable it?

    Code:
            [HttpGet]
            public async Task<IActionResult> Logout()
            {
                HttpContext.Session.Clear();
    
                await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
    
                return RedirectToAction("Login", "User");
            }
    Anybody can help me, please?

    Stay safe and keep healthy

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: How to disable user's browser back-button after they logged-out?

    You should have Authorize attributes on your controllers and/or actions if the user needs to be logged in to access them. If you do that then it shouldn't matter if they try to go back to a page that required authorisation.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width