JONDJONES.COM
  • About
  • CMS
  • Clean C#
  • Javascript
  • Resources
  • Ask Jon
  • Hire Me
  • Contact
Follow Me
  • ;

what are you looking for?

JONDJONES.COM
  • About
    About Me
    • Who Is Jon D Jones?
    • Things I Use
    • My Projects
    How You Can Help
    • How You Can Support This Site
    • Submit A Guest Post
  • CMS
    CMS Tutorials
    • Umbraco
    • Sitecore
    • Episerver
    Resources
    • Episerver: The Missing Manual
    • #ILoveEpiserver
    • #ILoveUmbraco
  • Clean C#
    • TDD
    • Clean Code
    • Devops
    • Faster Page Load Times
    • Developer Tool Tutorials
  • Javascript
    Tutorials
    • Javascript
    • React
    • CSS
    Resources
    • #ILoveJavascript
    • Dev Tools List
    • #ILoveReact
  • Resources
    Free Guides
    • Shit My Websites Down...
    • #ILoveJavascript
    • #ILoveReact
    • #ILoveTechnicalInterviews
    • Land Your First Contract
    Books
    • Episerver Missing Manual
  • Ask Jon
  • Hire Me
    My Services
    • Umbraco Freelancer
    • Episerver Freelancer
    • Sitecore Freelancer
    • Javascript Freelancer
    My Company & Experience
    • Digital Prompt
    • My Portfolio
    • LinkedIn Profile
    • Stackoverflow CV
  • Contact

The Best Way To Manage Global Data Within Episerver

  • Homepage
  • Learn Episerver CMS
  • Episerver Developers Tutorials
  • Episerver Structuring Your Project
  • The Best Way To Manage Global Data Within Episerver
Needing access to site settings is definitely not a new challenge.  I've been creating .NET CMS solutions for over ten years now and from my first project up until my most recent, every site has needed one.  If you are new to CM development then think of these settings as things like the Search page Url, the contact us page or the check out page for a commerce site. Over the years, I've used a variety of ways to add settings into an EPiServer site.  This article will discuss the benefits of some of the more popular methods.

Storing them in the StartPage

This one is one of the most common approaches.  You create a new tab called setting on your home/start page and add everything in there. Using this approach is very easy as you can access the StartPage using ContentReference.StartPage. For access wise this is pretty easy, however, on some projects the amount of settings can bloat very quickly.  When you use the StartPage on a high load site, loading up all this unneeded settings data and, from the other side, passing around the unneeded start page settings, adds more unneeded bandwidth on your server.

Creating a Setting Page Type

This is also another one of the more popular choices. You create a SettingsPageType and define everything you need in it.  The setting page can leave under the root page and you can easily get access to it using:
var repository = ServiceLocator.Current.GetInstance<IContentLocator>();
var settingPage = repository .GetChildren<SettingsPageType>(ContentReference.RootPage);
Doing it this way means you don't have any unwanted data in your start page and you don't have any unneeded homepage data being passed around when you only care about settings.  In 9 out of 10 cases, this is the approach I use now.  It also means you can block access CMS editor pages. Some of the other benefits include version history and language management.

Creating an admin page

This way is a bit more old school.  You can create an admin page to store your settings.  This means you can prevent content editors having access to it completely.  I've always found though that people forget where it is and then struggle to find it, which is why I favour the settings page with restricted permissions.  You also lose your paging version history and language management, if you need different settings on a multi-language site, this is definitely not the right approach.

App Settings

Do not go down this route. You store the pages Id for key pages in your app setting.  This way is very clunky and prone to errors.  If you delete pages and recreate them, your app settings will break. This also requires a potential code release to update.  Yuk!

A Settings Assembly

I used this approach a few times, you create a separate assembly that has a lots of static consts that just stored settings.  This means only developers can update settings.  When you want to change a setting, it does require a release but that release is contained in it's own assembly, so you can deploy that without needing to do a full website release. I used to like this approach a lot but it is very flexible.  In times pre CI, when you manually copied files onto a server, this was a pretty simple approach.  Post continuous integration, I've never used this approach as it's too inflexible and adds too much risk creating a full release package.

A Setting Block

Now we have blocks, instead of creating a setting page, we can create one or more settings blocks. Creating blocks is a nice approach because it's not a page, you’ve still got all your Epi content pro's like version history, language management.  The downside of using one or more blocks for smaller sites is you need to manage one or more areas.

Conclusion

That draws us towards the end of this discussion.  For preference, I think the page settings is the best approach with the settings block a close second.  Having your settings data separate reduces the network bandwidth and having it within Episerver so you don't need to do a dev release will save you a lot of frustration down the line.
Creating A Custom View Engine To Organise Your Pages and Block Views  More Easily
Creating A Custom View Engine To Organise Your Pages and Block Views More Easily
How To Deal With Large Amounts Of PageTypes
How To Deal With Large Amounts Of PageTypes
How To Structure Your Epi-Server Project
How To Structure Your Epi-Server Project
Respect The Block! How To Decide What Should Be A Block When You Start A New Episerver Project
Respect The Block! How To Decide What Should Be A Block When You Start A New Episerver Project
The Best Way To Manage Global Data Within Episerver
The Best Way To Manage Global Data Within Episerver
FOUND THIS TUTORIAL USEFUL? PLEASE CONSIDER DONATING
BECOME AN EPISERVER PRO
Episerver Missing Manual
FIND OUT MORE
HIRE ME
Need An Episerver Freelance Developer
Episerver EMVP
FREE BOOK
Shit My Websites Down
DOWNLOAD NOW

Subscribe

Join us today and get instant access to FREE books

YOU ARE A LEGEND!

You just made.. THE LIST!

SUPPORT THIS SITE
CLICK AN AD!

WELCOME

Hi, I'm Jon, I write articles about creating and optimizing websites to help your business meet its goals. I am a technical architect and technology fanatic by profession. You can find out more about me by joining my newsletter.

Latest Posts
  • Umbraco V8 Fails To Load On Remote Server
  • How To Enable Optional Chaining Within Your Javascript Project
  • How To Call An API Within A React.js App
  • Quick And Dirty Guide To Deploying Your React App

© Jon D Jones