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;
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
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
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();
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
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();
var pages = App.WorkWith().Pages().LocatedIn(Telerik.Sitefinity.Fluent.Pages.PageLocation.Frontend).Where(page => page.ShowInNavigation ==
true
&& page.ApprovalWorkflowState ==
"Published"
).Get().Reverse();