I have a scheduled task that requires a reference to the start page, but ContentReference.StartPage is null in this situation.
From what I have seen other people get round this by putting * in as host - but I am pretty sure the client is not going to go for that on prod and anyway it feels like a bodge (workaround for bad code).
What is the correct way to get a reference to the start page in this situation?
Since a scheduled job is outside the Context, Episerver don't know WHICH start page you'd be referring to in case you'd have a multi site setup, and which language.
Check the SiteDefinitionRepository
var siteDefinitionRepository = ServiceLocator.Current.GetInstance<SiteDefinitionRepository>();
var siteDefinitions = siteDefinitionRepository.List().ToList();
foreach (var siteDefinition in siteDefinitions)
Check what you can do with the SiteDefinition here. For example siteDefinition.StartPage
Thanks a lot Alf - thats excellent. :)