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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:57:29+00:00 2026-05-13T15:57:29+00:00

I have created a master page (Site.master) which contains the code to display a

  • 0

I have created a master page (Site.master) which contains the code to display a header, a footer, and a side bar. It works really great, but I am having trouble figuring out how to dynamically choose the header.

Basically, there are two possible header options. If the user is not logged in, I want them to see a login box and links for recovering their password, etc. If they are logged in, they’ll see a logout link, and some information about their account (similar to how SO works, actually).

Is it possible to have the Site.master check and use whichever header I want depending on the login status of the user? I’m pretty stuck on where to begin with this (I thought maybe some checks in the code-behind of the master page) so any help would be 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-05-13T15:57:29+00:00Added an answer on May 13, 2026 at 3:57 pm

    You should consider using the built-in control, LoginView (MSDN). It is specifically designed to provide multiple templates (views), for authenticated and anonymous users.

    This is a best practice approach. You can define your headers/footers etc. for logged in and anonymous users, with appropriate login/logout buttons, user information, etc. etc.

    Here’s a very basic example:

    <asp:LoginView id="LoginView1" runat="server">
        <AnonymousTemplate>
            <asp:HyperLink ID="lnkLogin" runat="server" NavigateUrl="~/Login.aspx" Text="Login"/>
        </AnonymousTemplate>
        <LoggedInTemplate>
            You are logged in as: <asp:LoginName id="lnCurrentUser" runat="server" />.
        </LoggedInTemplate>
    </asp:LoginView>
    

    The .NET framework will handle the rest, and display the correct template without any extra code. If you end up using multiple roles in your application you can take this one step further and define templates for these roles as well (administrator vs regular user, etc.)

    A perfect solution to your question based on the above: How to: Display Different Information to Anonymous and Logged In Users

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

Sidebar

Ask A Question

Stats

  • Questions 304k
  • Answers 304k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Use JOIN to join the subqueries and use ON to… May 13, 2026 at 8:56 pm
  • Editorial Team
    Editorial Team added an answer Yes, you're leaking memory. Whenever you allocate memory with the… May 13, 2026 at 8:56 pm
  • Editorial Team
    Editorial Team added an answer When you set the value of the select box, are… May 13, 2026 at 8:56 pm

Related Questions

I have created a custom list in a SharePoint site and generated a Visual
I'm currently trying to user actionlink helpers in a way that I don't think
I've been playing around with ASP.NET MVC with a site containing a Master Page.
I am totally new to Sharepoint (2007) so please bear with me. I would
I created a default ASP.net MVC project. In the Master page I have the

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.