How To Get A Page Types Id

There are a few times in Episerver when you need to know a page types Id.  In Episerver 6 you use the GetPageTypeID-method that return the Id. In Episerver 7 and upwards this has moved.  To access the code now you can use the IContentTypeRepository. In IContentTypeRepository you have useful features like Load<>, Save<>, Delete<> and List() to get a list of all page types in your website.

var pageTypeId =
    ServiceLocator.Current.GetInstance<IContentTypeRepository>()
    .Load<PageType>()
    .ID;

submit to reddit

Jon D Jones

Software Architect, Programmer and Technologist Jon Jones is founder and CEO of London-based tech firm Digital Prompt. He has been working in the field for nearly a decade, specializing in new technologies and technical solution research in the web business. A passionate blogger by heart , speaker & consultant from England.. always on the hunt for the next challenge

Back to top