Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9156861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:52:20+00:00 2026-06-17T12:52:20+00:00

I am using FormsAuthentication for userlogin. I am having a problem after user logs

  • 0

I am using FormsAuthentication for userlogin.
I am having a problem after user logs out successfuly the back button is browser allows user to view pages.
I tried using javascript

 <script type = "text/javascript" >
        function preventBack() { window.history.forward(1); }
        setTimeout("preventBack()", 0);
        window.onunload = function () { null };
</script>

But back button is completly disabled.
It worked bt,I dont want to disable back button functionality when user is logged in. i want my LOGGED IN user to use browser back button as normal. But once he choosed to log out, he is not allow to see any of contents by pressing Back.
I also tried using

Session.Abandon();
 Response.Cache.SetCacheability(HttpCacheability.NoCache);
 Response.Cache.SetExpires(DateTime.Now);

But this is also not working.how do I fix this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T12:52:21+00:00Added an answer on June 17, 2026 at 12:52 pm

    You could clear the browser history when the user logs out:

    var url = window.location.href;
    window.history.go(-window.history.length);
    window.location.href = url;
    

    However this would not be particularly robust – it relies on javascript, it would not work across multiple tabs and may only serve to annoy the user. IMO the best bet is to set appropriate caching headers such that the browser will not cache any of your ‘logged in’ pages via a NoCacheAttribute applied appropriately:

    public class NoCacheAttribute : ActionFilterAttribute
    {  
      public override void OnResultExecuting(ResultExecutingContext filterContext)
      {
          filterContext.HttpContext.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1));
          filterContext.HttpContext.Response.Cache.SetValidUntilExpires(false);
          filterContext.HttpContext.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
          filterContext.HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache);
          filterContext.HttpContext.Response.Cache.SetNoStore();
    
          base.OnResultExecuting(filterContext);
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After checking a user's credentials and confirming they are good, I'm using FormsAuthentication.SetAuthCookie(Username, false);
Using this code for authentification: HttpContext.Current.User=new GenericPrincipal (new GenericIdentity(user.UserName), roles); FormsAuthentication.SetAuthCookie(user.UserName,false); Problem is -
I have authenticated users to log on my system using this code: FormsAuthentication.SetAuthCookie(user, false);
I am using FormsAuthentication.SetAuthCookie Method in my application.after Client login i am setting FormsAuthentication.SetAuthCookie(txtUserNo.Text.Trim(),
I am using a C# Webservice to log a user out. I am using
How do I tell if a user is authenticated (logged in) using FormsAuthentication? <authenticaion
I have problem with Uploadify: I log in the project using: FormsAuthentication.SetAuthCookie(myName, false); Then,
I'm using FormsAuthentication to allow users to login. However I have a Excel file
hi we are using FormsAuthentication.SetAuthCookie(profile.Id, false); Now the question is when does this cookie
I see the guidance when using formsAuthentication in ASP.NET is to use SSL via

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.