Check if page exists
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();
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();
I'm working around this by using the PageManager instead:
PageManager.GetManager().GetPageNodes().Where(p => p.Title ==
"abc"
&& p.Parent.Title ==
"xyz"
).FirstOrDefault();
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
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
Hi Eric,
OK, will check it there.
Greetings,
Ivan Dimitrov
the Telerik team