Try our conversational search powered by Generative AI!

Get all the page types that are of type PageData or inherited class

Vote:
 

Hi all,

I would like to get all the available page types in episerver that are a Page Data. For that I'm doing:

 var contentTypeRepository = ServiceLocator.Current.GetInstance();

var pageTypeList = contentTypeRepository.List().OfType();

The problem is when I try to check if a page is at PageData this doesn't work. The idea is to filter all those pages that are in the pageTypeList.

How I can do that?

Thank you

#191671
Apr 26, 2018 11:05
Vote:
 

You could filter in ContentType.ModelType, like:

            var contentTypeRepository = ServiceLocator.Current.GetInstance<IContentTypeRepository>();
            var pageTypeList = contentTypeRepository.List().Where(c => typeof(PageData).IsAssignableFrom(c.ModelType));
#191679
Apr 26, 2018 11:54
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.