More in this section

Forums / General Discussions / Check if page exists

Check if page exists

5 posts, 0 answered
  1. Eric
    Eric avatar
    147 posts
    Registered:
    12 Nov 2007
    14 Jan 2011
    Link to this post
    I'm trying to check if a page exists with the following code

    PageNode page = App.WorkWith().Pages().Where(p => string.Compare(p.UrlName, url, true) == 0).Get().FirstOrDefault();

    But I get the following exception:
    Telerik.Sitefinity.Pages.Model.PageNode, Telerik.Sitefinity.Model was not granted View in Pages for principals with IDs 00000000-0000-0000-0000-000000000000

    Based on another thread, I checked if the item's page item was not null. I also checked to make sure the Id wasn't empty. No luck.
    PageNode page = App.WorkWith().Pages().Where(p => p.Page != null && p.Id != Guid.Empty).Where(p => string.Compare(p.UrlName, url, true) == 0).Get().FirstOrDefault();

    Any suggestions?

    Thanks,
    Eric
  2. Eric
    Eric avatar
    147 posts
    Registered:
    12 Nov 2007
    17 Jan 2011
    Link to this post
    I'm working around this by using the PageManager instead:

    PageManager.GetManager().GetPageNodes().Where(p => p.Title == "abc" && p.Parent.Title == "xyz").FirstOrDefault();

    This seems to be working. Not sure why the Fluent code wasn't working, but PageManger (in this case) works just as well.
  3. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    19 Jan 2011
    Link to this post
    Hello Eric,

    "Telerik.Sitefinity.Pages.Model.PageNode, Telerik.Sitefinity.Model was not granted View in Pages for principals with IDs"  is usually thrown when the user you use does not have permissions to view a page.

    Try using some simple code like this one shown below

    PageNode page = App.WorkWith().Pages().Where(p => p.UrlName == "Login1").Get().FirstOrDefault();

    Create a local variable where you set the value of string.Compare(p.UrlName, url, true) == 0) and then check

    p.UrlName == myvariable

    instead of injecting the code in the expression brackets

    Best wishes,
    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
  4. Eric
    Eric avatar
    147 posts
    Registered:
    12 Nov 2007
    19 Jan 2011
    Link to this post
    No luck. I used the code exactly as provided (expecting to get null back) and then I tried changing the UrlName to a page that did exist. Same exception.

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

    Higgsy posted this in the bugs forum yesterday. If you want to close this and pick it up over there, that's fine with me -- avoid double work on your part.
    http://www.sitefinity.com/devnet/forums/sitefinity-4-x/bugs-issues/bug-with-app-workwith-pages.aspx
  5. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    19 Jan 2011
    Link to this post
    Hi Eric,

    OK, will check it there.

    Greetings,
    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
5 posts, 0 answered