How to get a page property value from the start page in EPiServer

When browsing through google analytics, it’s interesting to see what people search for to find your blog. So, I will try to make a few blog posts about the most frequent search terms so it will be easier to find. 🙂

If you have a property that you need to use all over the site, a global setting, then one way is to add that property to the startpage. (If you have a lot of settings it might be handier to have a special page and page type where the settings are stored.)

To access that property you first need to get the pagedata object for the start page, and then it’s easy to access the property.

var startPage = DataFactory.Instance.GetPage(PageReference.StartPage);

var property = startPage["PropertyName"];

If you are using PageTypeBuilder, you can access the property strongly typed by

var startPage = DataFactory.Instance.GetPage(PageReference.StartPage) as StartPageType;

var property = startPage.PropertyName;