Welcome to the navigation

Ullamco commodo dolore laborum, eu ut id in ad incididunt nostrud in non do dolor ut voluptate enim amet, culpa dolore pariatur, exercitation duis nulla. Officia fugiat tempor ullamco laborum, commodo aute qui aliquip ut adipisicing pariatur, esse deserunt ex in consectetur ea in laboris elit, exercitation irure veniam, nisi

Yeah, this will be replaced... But please enjoy the search!

Get the SiteDefinition for a specific page in Episerver using SiteDefinitionResolver

If you have a multi site/tenant Episerver setup and need an effective way to figure out the current SiteDefinition the SiteDefinitionResolver is the way to go. This may be very useful when you need to figure out the current StartPage, SiteUrl and similiar properties in a multi site environment.

Before Epi 10

var siteDefinitionResolover = ServiceLocator.Current.GetInstance<SiteDefinitionResolver>();
SiteDefinition siteDefinition = siteDefinitionResolover.GetDefinitionForContent(
    contentLink: contentLink, 
    fallbackToWildcardMapped: true,
    fallbackToEmpty: true);

Epi 10 and later

var siteDefinitionResolover = ServiceLocator.Current.GetInstance<ISiteDefinitionResolver>();
SiteDefinition siteDefinition = siteDefinitionResolover.GetByContent(
    contentLink: this.ContentLink,
    fallbackToWildcard: true,
    fallbackToEmpty: true);

 

This will enable you to access the properties through the siteDefinition variable

// get the startpage of the stated contentLink
var startPage = siteDefinition.StartPage;
// get the site url for the stated contentLink
var siteUrl = siteDefinition.SiteUrl;

Read more on SiteDefinition and SiteDefinitionResolver

Please note that this portal is a BETA site , I will continuously improve all functionality and performance during the coming weeks / the author