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 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

Related Questions

I have created a master page in asp.net which dont have any server side
I have created a control on my Site.Master page which pulls data from an
I have a project where a .master page was created without a code behind
I have a Master Page which controls the styling of my site. In the
I have a web site with a series of Master Pages which all derive
I created a default ASP.net MVC project. In the Master page I have the
I have signed up for office 365 which provides sharepoint site. I have created
With the way my site is setup, I have a master page, page and
I have some css issue which I don't understand. I have created default mvc
I am validing the default.aspx(uses master page) of my web site, however; I am

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.