Try our conversational search powered by Generative AI!

Site definition id in DXP



When i do , I get value when running in local while the same thing resolves to empty guid when deployed in DXP. Why would that be ?

Mar 07, 2021 23:47

Are you running in context of a scheduled job? 

Mar 08, 2021 9:07

Hello Quan,

No am not running in schedule job context. I am calling profile store api and using site id as one of the parameter from website itself (since my applicaiton has multi site) to filter site content accordingly.

This seems to be working fine while in local but in DXP it always gives me empty GUID

Mar 08, 2021 16:19

When you run following code, does it gives you list of Sites?

var siteDefinitionRepository = context.Locate.Advanced.GetInstance<ISiteDefinitionRepository>();
var siteDefinitions = siteDefinitionRepository.List();
Mar 09, 2021 20:18

Here's the code I use in DXP environment to get the siteId and do something with it. However we only have one site, you may need to change ContentReference.StartPage accordingly if you have multiple sites.

public void Initialize(InitializationEngine context)
    var resolver = context.Locate.Advanced.GetInstance<ISiteDefinitionResolver>();
    var site = resolver.GetByContent(ContentReference.StartPage, fallbackToWildcard: true, fallbackToEmpty: false);
    var siteId = site.Id;
//Your logic here }
Apr 09, 2021 8:08
* 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.