Try our conversational search powered by Generative AI!

Get PageTypeId from ContentType-model


I've started upgrading one clients Episerver 6-site to Episerver 7 and I need to get the PageTypeId from certain page types in order for the code to work on many places (like sorting, etc).

On their Episerver 6-site we're using PageTypeBuilder which has a GetPageTypeID-method that return the Id but we're switching to Episerver 7's way of building page types so we can't use that method.

I can clearly see the Page type Ids when I hoover over the Create-link on the create new page-page so there must be a way to extract it by code if I know the page-type (typeof(Models.StartPage)

Jan 25, 2013 17:18


var startPageTypeId = 


Jan 25, 2013 22:25

Thank you!

Jan 28, 2013 9:49
Jan 29, 2013 15:43

Use the interface rather than the concrete class to achieve this because there is a structure map exception when you deal with the class directly.

So, it is

var startPageTypeId = ServiceLocator.Current.GetInstance<IContentTypeRepository>().Load<StartPage>().ID;

Edited, Oct 07, 2013 1:59
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.