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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T23:41:31+00:00 2026-05-21T23:41:31+00:00

Here is the sequence in which events occur when a master page is merged

  • 0

Here is the sequence in which events occur when a master page is merged with a content page:

http://msdn.microsoft.com/en-us/library/dct97kc3.aspx

So, my problem is:

I have one login page (not use master page), one master page, and hundreds of content page.

I check login session Session["loggedInUser"] in master page (if not logged in, redirect to login page)

So, when I don’t log in, if I type the address of one content page, it must check login session in master page and redirect to login page, right? But it has two cases here:

If in content page, I don’t use anything related to Session["loggedInUser"], it will redirect to login page, so, it’s OK here!

The second case: if I use Session["loggedInUser"] to display Username in content page for example:

UserInfo loggedInUser = (UserInfo)Session["loggedInUser"];

it will return null object here, because the page_load in content page is fired before page_load in master page, so it thows null object instead of redirecting to login page.

I also tried Page_PreInit in master page but no help

protected void Page_PreInit(object sender, EventArgs e)
{
    if (Session["loggedInUser"] == null)
    {
        Response.Redirect("~/Login.aspx");
    }
}

Any suggestion?

  • 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-05-21T23:41:32+00:00Added an answer on May 21, 2026 at 11:41 pm

    Finally I’ve come up with a solution:

    I create a class BasePage like this:

    public class BasePage : System.Web.UI.Page
    {
        protected override void OnLoad(EventArgs e)
        {
            if (Session["loggedInUser"] == null)
            {
                Response.Redirect("~/Login.aspx");
            }
            base.OnLoad(e);
        }
    }
    

    And in the content page, instead of inheriting from Page, I change to BasePage and it works perfectly

    Thanks for all of your support

    Nice day 😉

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

Sidebar

Related Questions

Here's a really strange problem: Apparently, the specific sequence of bytes which translates to
Here is my code, which takes two version identifiers in the form 1, 5,
I am using a List construct to handle the sequence in which images are
I have a question regarding the reading sequence of an array which is converted
I've created a simple ribbon button which opens a new ASPX page and passes
I was trying to find the sequence in which magical methods are called in
There's a neat sequence in the movie The Social Network in which the character
I've got the following code which is based off an example i found here
here is the code : http://jsfiddle.net/yuliantoadi/hMr7h/ if you try to hover the 'test 2'
Here's task: We have an sql server database. which is hosted at our server.

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.