Vulnerability in EPiServer.Forms

Try our conversational search powered by Generative AI!

Get all the page types including draft pages



I'm trying to get all the pages of a particular type existing in the episerver tree. The problem is I only get the published pages. Not the ones that are in draft mode. I'm already use two techniques to get the pages:

  var criteria = new PropertyCriteriaCollection
                new PropertyCriteria
                        Condition = CompareCondition.Equal,
                        Name = "PageTypeID",
                        Type = PropertyDataType.PageType,
                        Value = Instances.GetLocalInstance().Load().ID.ToString(),
                        Required = false

            var pages = ContentReference.RootPage.FindPagesWithCriteria(criteria).OfType().ToList();


                        .FirstOrDefault(item => string.Equals(item.ImdProductId, page.ImdProductId, StringComparison.CurrentCultureIgnoreCase));

Can you help me please?

May 29, 2018 14:25

One way to solve this is to using GetChildren but with the language selector. This method only returns the published pages. When we use the Language selector we have all the pages.


articlePages = this._contentRepository.GetChildren<ArticlePage>(

Thank you

May 29, 2018 15:04

If you want to use FindPagesWithCriteria or similar you can use "FindAllPagesWithCriteria" which also requires a language to be defined:

var queryService = ServiceLocator.Current.GetInstance<IPageCriteriaQueryService>();
var pages = queryService.FindAllPagesWithCriteria(PageReference.StartPage, criteria, "en", new LanguageSelector("en"));

Just as a word of caution - FindPagesWithCriteria isn't the most efficient of methods as it calls the database directly, bypassing the cache so I'd consider my options before using it on the public facing part of your site.

May 29, 2018 15:15

You could use EPiServer.Core.IContent.IContentModelUsage.ListContentOfContentType(ContentType contentType).

May 30, 2018 9:06
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.