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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:36:33+00:00 2026-06-02T05:36:33+00:00

Im working with Umbraco 5.1 beta. On the internet (this information is from previous

  • 0

Im working with Umbraco 5.1 beta. On the internet (this information is from previous versions, could not find recent documentation on it) I find that I could ask a node if the user has Access. In that way I want to build up my menu. The thing is, I cant get it to work, the HasAccess and IsProtected properties are not working. What am I doing wrong? Or does it work different in the newer versions of Umbraco? (I also tried it as method, still no result)

This is the code I’m now using:

@inherits RenderViewPage
@using Umbraco.Cms.Web;

 @{
     var Homepage = @DynamicModel;
     while (Homepage.ContentType.Alias != "homePage")
     {
         Homepage = Homepage.Parent;
     }
 }
  <ul>
      <li><a href="@Homepage.Url">Home</a></li>
  @foreach (var item in Homepage.Children) {
      if(!item.IsProtected || (item.IsProtected && item.HasAccess)) {
          if(@item.CurrentTemplate != null) {
              var childName = item.Name ?? "(No name yet)";
              <li><a href="@item.Url">@childName </a></li>
          }
      }
  }
  </ul>
  • 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-06-02T05:36:35+00:00Added an answer on June 2, 2026 at 5:36 am

    If you are just looking to suppress nodes that the user cannot access. Then you can use the WhereCanAccess() method.

    Example: (This will hide all child nodes that the user doesn’t have access to)

    @inherits RenderViewPage
    @using Umbraco.Cms.Web;
    
     @{
         var Homepage = @DynamicModel;
         while (Homepage.ContentType.Alias != "homePage")
         {
             Homepage = Homepage.Parent;
         }
     }
      <ul>
          <li><a href="@Homepage.Url">Home</a></li>
          @foreach (var item in Homepage.Children.WhereCanAccess())
          {
              if(@item.CurrentTemplate != null)
              {
                  var childName = item.Name ?? "(No name yet)";
                  <li><a href="@item.Url">@childName </a></li>
              }
          }
      </ul>
    

    Trying to find if a node IsProtected seems to be somewhat more complex (although only a couple of lines of code. Well the only way I found find to do it anyway!)

    Example: (This just puts an * next to the name of protected menu items)

    @inherits RenderViewPage
    @using Umbraco.Cms.Web;
    
     @{
         var Homepage = @DynamicModel;
         while (Homepage.ContentType.Alias != "homePage")
         {
             Homepage = Homepage.Parent;
         }
    
         var appContext = DependencyResolver.Current.GetService<IUmbracoApplicationContext>();
     }
      <ul>
      <li><a href="@Homepage.Url">Home</a></li>
      @foreach (var item in Homepage.Children)
      {
          var isProtected = appContext.Security.PublicAccess.IsProtected(item.Id);
    
          if (@item.CurrentTemplate != null)
          {
              var childName = item.Name ?? "(No name yet)";
              childName = (isProtected) ? "* " + childName : childName; 
              <li><a href="@item.Url">@childName </a></li>
          }
      }
      </ul>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Working on a movie website and would love to find an API that I
I'm working on an Umbraco website and now I've built this contactform, on which
Working on THIS Page: newsite.702wedding.com/live/ Can't find where to remove the arrows at the
I'm working on a project that will use Umbraco for CMS capability, but also
I'm working on an umbraco 4.7.0 project and I have upgrated from 4.7.0 to
I'm working with Umbraco 4.7.1 and I've created some extensions that hook into Document.AfterPublish
I'm working with Umbraco 5.1 to implement this blogpost which describes how to create
Working on a bunch of forms at the moment and I'm finding that I
Working on a website that has Employee and Branch entities, using a database table
Working on calling a C function from my asm project. I'm trying to push

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.