Masterpage - Only show menu if logged in (authenticated)

5 posts, 0 answers
  1. Benson Group
    Benson Group  avatar
    5 posts
    Member since:
    Apr 2014

    Posted 17 Jun Link to this post

    Good morning,

    I started a new ASPX web site application, and chose to use the responsive theme.

    What I am trying to do, is only show the nav menu once I am logged in (with session variable, or other suggestion).

    I tried using some <% if session[varisset] %> code within the master page, but I get "code blocks are not supported in this content.

    I am also trying to code the masterpage.master to have an on load() that would redirect to login.aspx if not authenticated as well, but obviously not to continually redirect there if the web page is already at login.aspx.

    could anyone help me out with this? or point me in the right direction?

    Let me know if you require more info.

  2. Benson Group
    Benson Group  avatar
    5 posts
    Member since:
    Apr 2014

    Posted 21 Jun Link to this post

    Is anyone able to help me out with this?

    At the very least how to put if statements in a telerik code block?
    Thanks

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Nencho
    Admin
    Nencho avatar
    1457 posts

    Posted 22 Jun Link to this post

    Hello,

    You can manage the session variable at server-side in the code-behind of the Master Page that you use. For example, you can handle Page_Load and manage the visibility of the Menu, if the preferred session variable is set to a given value.

    As for the Login page redirect - you can implement this directly in your web.config. Please refer to the following thread, where such implementation is described:

    http://stackoverflow.com/questions/10955596/how-can-i-have-asp-net-automatically-redirect-non-logged-in-forms-users-to-the-l?answertab=votes#tab-top

    Regards,
    Nencho
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  5. Benson Group
    Benson Group  avatar
    5 posts
    Member since:
    Apr 2014

    Posted 23 Jun Link to this post

    "You can manage the session variable at server-side in the code-behind of the Master Page that you use. For example, you can handle Page_Load and manage the visibility of the Menu, if the preferred session variable is set to a given value."

     

    how exactly would this be done? at the moment, the menu portion is all in the MasterPage.Master (not the .cs page).

    would my menu have to be written in the code behind? or? I am just not sure how to do this.

    thanks

  6. Nencho
    Admin
    Nencho avatar
    1457 posts

    Posted 28 Jun Link to this post

    Hello,

    No, you are not obligated to dynamically create the RadMenu, in order to be able to manage its visibility state, base on a session variable.

    In the attachment you can find a sample project, demonstrating a possible variant of implementation.

    Regards,
    Nencho
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017