need master page links to show logged in state RRS feed

  • Question

  • User1300871232 posted

    we are using sessions and web services to log in and out.

    we are using the default master page which comes with visual studio 2012 if you go to create a 'web forms c# project' rather than an empty ASP application.

    What we want is for the master page to detect an active session.  If the session is active, the button 'log in' should change to 'log out' and the 'register' button should be removed.

    How can this be achieved?  Any links to examples, code samples, document etc?

    Tuesday, November 11, 2014 10:12 AM


  • User-760709272 posted
    // in your master page
    <asp:HyperLink ID="HyperlinkLogin" Visible="false" runat="server" NavigateUrl="~/Login.aspx">Login</asp:HyperLink>
    <asp:HyperLink ID="HyperlinkLogout" Visible="false" runat="server" NavigateUrl="~/Logout.aspx">Logout</asp:HyperLink>
    // in the page_load code-behind of your master page
    if (userIsLoggedIn)
        HyperlinkLogout.Visible = true;
        HyperlinkLogin.Visible = true;

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, November 11, 2014 10:55 AM