In the project where I only get ID=0, it is a single site solution with a single start page. In StartPage's controller later for instance I can access it.
I can access it through ISiteDefinitionRepository, but still strange.
Looks like what you are experiencing is expected:
If you in one project get the StartPage-value, maybe you are just lucky with the order of initialization.
The quick-and-dirty solution would be adding the content id to your start page to appsettings, and use that id in your initialization module.
Hi Zsolt
Do your site have a host definition with a wildcard ("*") for a hostname?
A site with this wildcard will be returned when the site cannot be determined.
Thank you for your answers, it explains the behavior. I will use SiteDeinifitonRepository in all cases to fetch the start page with the expected type, it works in all cases.
Hi,
I am trying to write a migration system which on startup creates all the new pages automatically. I use IInitializableModule for this, and in only one of our two projects I cannot access the StartPage inside Initialize() method. Later it is accessible.
[InitializableModule]
[ModuleDependency(typeof(InitializationModule))]
public class MigrationTasksInitializableModule : IInitializableModule
{
public void Initialize(InitializationEngine context)
{
/* here EPiServer.Web.SiteDefinition.Current.StartPage returns:
ID = 0, WorkID = 0, ProviderName = null
GetPublishedOrLatest: false
ID: 0
IsExternalProvider: false
IsReadOnly: true
ProviderName: null
WorkID: 0
*/
}
public void Uninitialize(InitializationEngine context)
{
}
}
What am I doing wrong?
Thanks,
Zsolt