Bug with App.WorkWith().Pages - Bugs & Issues - Bugs & Issues - Progress Community
 Bugs & Issues

Bug with App.WorkWith().Pages

  • Bug with App.WorkWith().Pages
  • Hi,

    I'm reporting the following as a suspected bug:

    I have a very simple navigation control for building the menu, the code is as follows:

    1.//get all published pages
    2.var pages = App.WorkWith().Pages().Where(page => page.ApprovalWorkflowState == "Published" && page.ShowInNavigation == true && page.Parent == page.RootNode).Get().Reverse();
    3. 
    4.//calculate number of pages
    5.int PageCount = pages.Count();
    6.int PageIndex = 0;

    The error is thrown on line 5. The error is:

    Telerik.Sitefinity.Pages.Model.PageNode, Telerik.Sitefinity.Model was not granted View in Pages for principals with IDs 00000000-0000-0000-0000-000000000000

    The error is only thrown when I view the public website in a browser that I am NOT logged into SiteFinity on. If I view the public website in the same browser that I am currently logged into SiteFinity on it works perfectly.

    Thanks
    higgsy
  • Hello higgsy,

    The anonymous user should have view permissions over the page object. This is why you are able to run the code without problems when you are logged in.

    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  • I had the same issue, the PageManager works. I'm using
    var page = PageManager.GetManager().GetPageNodes().Where(p => p.Title == "abc" && p.Parent.Title == "xyz" && p.ApprovalWorkflowState == "Published").FirstOrDefault();

    Try replacing "App.WorkWith().Pages()" with "PageManager.GetManager().GetPageNodes()". I don't understand Ivan's response, You can try this workaround.

    Eric
  • 243595_Capture.JPG
    Ivan,

    I dont think this is the case at all. Please see the attached screenshot - everyone has access to view pages.

    Eric has had exactly the same problem, but got round it using the PageManager. So there is a workaround, but this appears to me to be a bug. There is no point me always using a Workaround if it is a bug because it doesn't improve Sitefinity's reliability or ease of development.

    Please confirm.

    Regards,
    higgsy
  • The Pages collection has backend pages which anonymous (everyone) wouldn't have access to.

    I agree with you Higgsy, this is a bug. The workaround works for me since I'm not doing a lot in code and just needed to check if a page existed, which the PageManager worked like a champ for.
  • Hi,

    I'm sure it must be a bug. I extended my expression to include only the FrontEnd page location, and I still get the same error, code as follows:

    var pages = App.WorkWith().Pages().LocatedIn(Telerik.Sitefinity.Fluent.Pages.PageLocation.Frontend).Where(page => page.ApprovalWorkflowState == "Published" && page.ShowInNavigation == true && page.Parent == page.RootNode).Get().Reverse();

    Telerik?

    Regards,
    higgsy
  • 244495_GetPagesTest.zip
    Hi higgsy,

    I am not able to replicate the issue using the same code. I attached a short video. Could you try to replicate the issue on a new project which you can install for a minute through the Project Manager.

    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  • Hi all,

    I have been able to resolve this issue, and it is NOT a bug. For the purpose of building my own very simple, single level navigation controls I was originally using this code:

    //get all pages
                var pages = App.WorkWith().Pages().Where(page => page.ShowInNavigation == true && page.ApprovalWorkflowState == "Published").Get().Reverse();

    However, when I tried to view the website in a browser that I was not logged into the backend with, I always got the error:

    Telerik.Sitefinity.Pages.Model.PageNode, Telerik.Sitefinity.Model was not granted View in Pages for principals with IDs 00000000-0000-0000-0000-000000000000

    By adding the LocatedIn facade and setting this to FrontEnd, all my problems went away! Therefore, the updated code is:
    var pages = App.WorkWith().Pages().LocatedIn(Telerik.Sitefinity.Fluent.Pages.PageLocation.Frontend).Where(page => page.ShowInNavigation == true && page.ApprovalWorkflowState == "Published").Get().Reverse();

    This makes perfect sense when you think about it, an anonymous user would not, and should not have access to any of the backend page nodes.

    Hope it helps.

    higgsy