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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:06:08+00:00 2026-05-17T21:06:08+00:00

I have to build an ASP.NET website on which some functionalities will be available

  • 0

I have to build an ASP.NET website on which some functionalities will be available to logged-in users. I’m trying to understand the right thing in building my pages.

I’ve found the following code in Page_PreInit:

protected void Page_PreInit(object sender, EventArgs e) 
{ 
    if (Membership.GetUser() == null) //check the user.. Weather user is logged in or not
    {
        this.Page.MasterPageFile = "~/General.master";
    }
    if (Membership.GetUser() == "ADMIN") //check the ADMIN.. Weather ADMIN is logged in or not
    {
        this.Page.MasterPageFile = "~/ADMIN.master";
    }
    else
    {
        this.Page.MasterPageFile = "~/Member.master";
    }
}

But I don’t’ know if this is the right approach in designing an app.
Is it right to switch at runtime Master page according to username/role?
Can you give me some suggestions?

  • 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-17T21:06:08+00:00Added an answer on May 17, 2026 at 9:06 pm

    You wouldn’t normally change the whole master page for this sort of thing unless you really need the entire layout to be different.

    For simpler scenarios, you probably want to use the LoginView control. Have a read of this:

    http://asp.dotnetheaven.com/aspnet/doc/ctrlref/login/loginview.aspx

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

Sidebar

Related Questions

Currently I'm tasked with doing the daily build. We have an ASP.NET 2005 website
I have ASP.NET web pages for which I want to build automated tests (using
I have a website which is built on ASP.NET MVC and hosted on Windows
I have an asp.net application which is purely build using C#, CSS, Javascript. Now
I'm working on a ASP.NET website that on some requests will run a very
I have a website built using Asp.net and LinqToSql for Data Access. In a
I have nant set up to build my ASP.NET MVC project and it works
We have CC.NET setup on our ASP.NET app. When we build the project, the
I'm currently experimenting with build script, and since I have an ASP.net Web Part
I have built a number of asp.net servercontrols into a class library, & I

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.