Try our conversational search powered by Generative AI!

Help me in FindPagesWIthCriteria


hello all

I'd need some help in finding a page with a specific element in a contentarea placed in that page.

How can I do that using the method FindPagesWithCriteria?

PropertyCriteriaCollection criterias = new PropertyCriteriaCollection();
criterias.Add(new PropertyCriteria()                            
                    Name = "PageTypeID",                                
                    Condition = EPiServer.Filters.CompareCondition.Equal,                                
                    Required = true,                                
                    Type = PropertyDataType.PageType,                                
                    Value = contenttype.ToString()

criterias.Add(new PropertyCriteria()
                    Name = "author",
                    Condition = EPiServer.Filters.CompareCondition.Contained,
                    Required = false,
                    Type = PropertyDataType.String,
                    Value = "12345"
var listPage = DataFactory.Instance.FindPagesWithCriteria(PageReference.StartPage, criterias);

"author" is a contentarea containing a list of pages of type AuthorPage

Any help will be very appreciated.

Thank you

Aug 12, 2015 12:10

The best way I've found so far is to use the GetReferenceToContent from the IContentRepository and then ensure whether the ContentArea contains the information.

Read my blog at

This blog is based on EPiServer 7, for 7.5+ I would suggest that you look at ContentArea.Items instead of Fragments

Aug 12, 2015 12:52


I tested your code with FindPagesWithCreteria and it looks like it's working. I had one problem - I search for content with Id = 41 and in result collection I got also items with id's 410 and 241, etc.

So I modified second criteria it a little bit:

criterias.Add(new PropertyCriteria()
                Name = "MainContentArea",
                Condition = EPiServer.Filters.CompareCondition.Contained,
                Required = false,
                Type = PropertyDataType.String,
                Value =  "data-contentlink=\"25403\""

Now the value is provided with full "data-contentlink" attribute and I got only one result.

Of course you should also consider Alf's answer because the content fragment API (the Html in database) could change in future.

There are also two interesting repositories:

1) ContentSoftLinkRepository

var SoftLinkRepository = ServiceLocator.Current.GetInstance<ContentSoftLinkRepository>()

Using this repository you could find all contents referenced to provided content:

2) There is also IContentModelUsage

var contentUsage = ServiceLocator.Current.GetInstance<IContentModelUsage>();

where you could find all usages of content by it's type

Edited, Aug 12, 2015 13:39

IContentModelUsage is interesting but does it solve Claudio's problem?

Aug 12, 2015 14:17

First of all... thank you for your answers....

Now I'm trying to understand it better.

My solution was partially working, while what Grzegorz wrote is perfectly working but it depends a bit too much on how Episerver stores data in DB.

Using Alf idea (GetReferencesToContent(contentLink, false)) I don't have to use FindPagesWithCriteria and it means I can search only by author criteria.

Am I right or I didn't get the solution proposed?

Aug 12, 2015 15:33


When you say "search only on author critera", are you still referring to using FindPagesWithCriteria?

Otherwise, yes with my proposed solution you don't need to use FindPagesWithCriteria

Aug 12, 2015 15:49

yes sorry I meant that with your solution I can search only by author, while I wanted to manage 3 types of filter and to search pages with 3 possible criterias

Aug 12, 2015 16:44
* 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.