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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:33:44+00:00 2026-05-27T16:33:44+00:00

In my Web-project (ASP.NET) I need 2 different master pages. One for users like

  • 0

In my Web-project (ASP.NET) I need 2 different master pages. One for users like “Admin”, and one for the usual users. Where can I indicate what master page to load? How can I load the correct master page, depending on the user?

  • 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-27T16:33:45+00:00Added an answer on May 27, 2026 at 4:33 pm

    When your admin user try to log in check the username and password with the database and if the login credentials are valid, Set a session variable to indicate this is an admin session. Then you can have a method which returns true of false by checking the session value to tell you whether the current user is an admin or normal user.

    When admin login is successfull, set this session variable

     Session["adminUserName"]=txtUserName.Text;
    

    Then write a method to check whether the current user is an admin or not

      public bool IsAdmin()
      {
        if(Session["adminUserName"]!=null)
        {
            return true;
        }
        else
        {
            return false;
        }
      }
    

    Have this method in a common place (like your base class or so ) and check during the page life cycle and load the appropriate master page.

       void BasePage_PreInit(object sender, EventArgs e)
        {
            if(IsAdmin())
            {
               MasterPageFile = "~/MasterAdmin.master";
            }
            else
            {
                 MasterPageFile = "~/MasterNormal.master";
            }
        }
    

    If Its an ASP.NET MVC application, You can check this in your ActionMethod.

    public ActionResult Index()
    {
     if(IsAdmin())
     {
       return View("Index", "MasterAdmin");
     }
     else
     {
       return View("Index", "MasterNormal");
     }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to get existing web pages into an existing ASP.NET web site project
I modify asp.net Web Site. I need use different connection strings for users. Web
I'm working on an ASP.NET (C#) web project that is using master pages. I'm
I'm trying to use SWFUpload with an ASP.NET Web Forms project. I need to
I have a ASP.net Web forms project that I am working on. I need
I have an ASP.NET (.asmx) Web Service project that has a method like: public
Suppose you have two seperate ASP.NET Web Application projects that both need to use
I have a Silverlight project (with ASP.net MVC web project) Suddenly, when I press
When deploying a web project written in ASP.Net, what happens to user sessions? Do
I have a asp.net web project I am working on, and found out my

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.