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 8874565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:45:12+00:00 2026-06-14T18:45:12+00:00

I have two pages, a login page and a page1. The user cannot directly

  • 0

I have two pages, a login page and a page1. The user cannot directly navigate to page1 as it contains following code for the pageload event. The user is redirected to the login page.

if (Session["role"] == null)
{
    Response.Write("Redirect Not Working");
    Response.Redirect("loginpage.aspx");
}

When the user clicks logout on pag1, he/she is redirected to the login page after setting Session["role"]=null. Now on the login page, if the user clicks on the browser back button, he/she is able to navigate to page1. Only in this case Response.Redirect("loginpage.aspx"); in pageload event does not work. Why does it not work? How can I make it work, or how can I prevent the user from accessing page1 in this scenario?

I have been helpless and closed last time by asking it a different way code to detect browser back button click for any(all) browser

Edit In response to answers: The code against the logout button is

protected void btnLogOut_Click(object sender, EventArgs e)
{
    Session["role"] = null;
    Session.Abandon();
    Response.Redirect("login.aspx");
}
  • 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-14T18:45:14+00:00Added an answer on June 14, 2026 at 6:45 pm

    The page you’re seeing on back may just be a cached version.

    The simplest way might be, instead of using response redirect, echo a meta refresh. You need to make sure the session is clear too.

    Session.Abandon();
    Response.Write("<meta http-equiv='refresh' content='0';URL='loginpage.aspx'>");
    Response.End();
    

    If a user hits back they’ll hit that page again and be bounced to the URL you want them at. Nothing stopping them from hitting back quickly more than once or choosing Page1 from the history drop down and getting a cached version.

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

Sidebar

Related Questions

I have two pages, on the first page after an event happens I change
Currently I have two pages: The first page contains an input form, and the
lets say i have two pages links.html & contents.php ... first page contains only
I have two pages load at beginning, login page and register page. Register page
I have written a code for a login page and user page. When the
I have two pages, one that edits user information, and one that edits information
I have two pages, NonMember.aspx and Member.aspx. If a user comes to the site,
I have two pages that inherit from one master page, First.aspx or second.aspx. Navigation
I have two different pages in my WP7 Application, Page1 and Page2. On the
I have two pages 1.php and 2.php 2.php (which is the secret page) can

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.