Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more

How to get page Start id in Episerver 7.5

Vote:
 

Hi,

I have below code in episerver 6 

var startPage = EPiServer.DataFactory.Instance.GetPage(new PageReference(EPiServer.Configuration.Settings.Instance.PageStartId));

How to convert this to episerver 7.5 

Please suggest

#208406
Oct 23, 2019 12:33
- Oct 23, 2019 12:35
is the below correct ?
var startPage =
EPiServer.DataFactory.Instance.GetPage(
new PageReference(EPiServer.Web.SiteDefinition.Current.StartPage));
Vote:
 

Hi Dinesh,

Please use this-

EPiServer.Core.ContentReference.StartPage
#208412
Oct 23, 2019 13:05
Vote:
 

For 7.5 you should be using IContentRepository instead of DataFactory. And new PageReference(EPiServer.Configuration.Settings.Instance.PageStartId) is now replaced with EPiServer.Web.SiteDefinition. ContentReference.StartPage can also be used as it is equipvalent to SiteDefinition.Current.StartPage by default. 

#208415
Oct 23, 2019 13:16
- Oct 23, 2019 13:22
Thanks very much Mai,

One more help , how will i get the siteDisplayName , in the below code please
EPiServer.Configuration.Settings.Instance.SiteDisplayName
Quan Mai - Oct 23, 2019 13:25
It would be SiteDefinition.Current.Name
- Oct 23, 2019 13:31
Hi,
The above gives you site id not name .. in my case i am getting 321
- Oct 23, 2019 13:40
Got it i changed in the Admin the site name
* 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.