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

  • SEARCH
  • Home
  • 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 9197815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:09:09+00:00 2026-06-17T22:09:09+00:00

My asp .net application is facing issue where logged out users are using browser’s

  • 0

My asp .net application is facing issue where logged out users are using browser’s back-button to revisit previously accessed page. User cannot perform any server side events , but it would be much better if user are not allowed to view this page at all. I searched for a solution to stop this but most of the solution include writing code inside page that must be not be revisited like this one.

 protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            string sb;
            sb = "<script language=javascript>\n";
            sb += "window.history.forward(1);\n";
            sb += "\n</script>";
            ClientScript.RegisterClientScriptBlock(Page.GetType(), "clientScript", sb);
        }

This means that i will have to write code in every page that a logged-in user can visit .
Is there a better way to handle this issue? Im expecting an optimized solution whereby I will not have to write code in every page . Help will be much appreciated.

  • 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-17T22:09:10+00:00Added an answer on June 17, 2026 at 10:09 pm

    Based on your question, I understand you only want to prevent the usage of the Back button (to see previous data), but that your server-side works correctly and doesn’t allow logged-out users to perform any tasks…

    If this is not the case, you should also add validation in your server side to make sure that a logged out user (which should be treated just like a user who never logged in) cannot do anything that requires permissions…!

    Back to your question – you should disable caching in the browser.

    In CodeBehind:

    Response.Cache.SetNoStore();
    Response.Cache.SetExpires(DateTime.UtcNow.AddHours(-1));
    Response.Cache.SetCacheability(HttpCacheability.NoCache);
    

    You can also use META tags in the ASPX page:

     <META Http-Equiv="Pragma" Content="no-cache">
     <META Http-Equiv="Expires" Content="0">
     <META Http-Equiv="Cache-Control" Content="no-cache">
    

    This will tell the browser that the page should not be cached and will not be reshown via the Back button

    If this isn’t enough, you can also use JavaScript to clear the history, here is an example

    Edit:
    And if you want this code to appear only once, you can create a BasePage (that derives from Page) which has this logic. Then, any page in which you want this logic should derive from the BasePage instead of the regular System.Web.UI.Page

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on ASP.net MVC3 Web application that is facing scalability issue. For improving
I am facing very critical issue with my asp.net web application in which i
I am facing some questions when trying to design an S3 application using ASP.NET
My asp .net mvc3 web application is facing issue which is application assigning same
I'm facing a very buggy issue, in ASP.NET application after viewing the same report
I'm facing an issue I don't quite understand. I'm developing an application in C#/ASP.net
My asp.net application is not using formsauthentication. Instead we make a call to database,
using VS 2008 i created a clean asp.net MVC application project and changed nothing
what's up? I'm facing a problem with IIS 7.5 application, asp.net MVC 3 and
I am facing this bizarre problem in my asp.net mvc application: In one page

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.