Check if page exists

Posted by Community Admin on 03-Aug-2018 23:32

Check if page exists

All Replies

Posted by Community Admin on 14-Jan-2011 00:00
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
Posted by Community Admin on 17-Jan-2011 00:00
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.
Posted by Community Admin on 19-Jan-2011 00:00
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
Posted by Community Admin on 19-Jan-2011 00:00
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
Posted by Community Admin on 19-Jan-2011 00:00
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
This thread is closed