More in this section

Forums / Bugs & Issues / Bug with App.WorkWith().Pages

Bug with App.WorkWith().Pages

8 posts, 0 answered
  1. higgsy
    higgsy avatar
    336 posts
    Registered:
    05 Aug 2010
    17 Jan 2011
    Link to this post
    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
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    17 Jan 2011
    Link to this post
    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
  3. Eric
    Eric avatar
    147 posts
    Registered:
    12 Nov 2007
    17 Jan 2011
    Link to this post
    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
  4. higgsy
    higgsy avatar
    336 posts
    Registered:
    05 Aug 2010
    18 Jan 2011
    Link to this post
    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
  5. Eric
    Eric avatar
    147 posts
    Registered:
    12 Nov 2007
    18 Jan 2011
    Link to this post
    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.
  6. higgsy
    higgsy avatar
    336 posts
    Registered:
    05 Aug 2010
    18 Jan 2011
    Link to this post
    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
  7. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    20 Jan 2011
    Link to this post
    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
  8. higgsy
    higgsy avatar
    336 posts
    Registered:
    05 Aug 2010
    27 Jan 2011
    Link to this post
    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
8 posts, 0 answered