Table of Contents

Page Service to set Title, Headers and Activate Features

In 2sxc 12.02 we introduced the IPageService which helps you to do things like

  1. Set the page Title, Keywords, Description or Base-Tag
  2. Add Meta-headers
  3. Add Icons or Icon-Sets
  4. Create JsonLD headers
  5. Activate page features like turnOn
Discover More in the Razor Tutorials

We have an rich series of Razor tutorials. You should really check them out 👍.


A Razor template is standalone - the page requests that it's rendered, but there is no official way to also tell the page that the title should change or that certain headers must be set.

We approached it in a futuristic way because we wanted to make sure that the code you write works in Dnn and Oqtane. So here's how it works

  1. Your code will get a IPageService object using `GetService<IPageService>()
  2. Your code can then tell it what you need - like SetTitle(...) or AddJsonLd(...)
  3. Once the Razor is done, the engine will forward these requests to the page and ensure it happens

👉 Read about Dependency Injection 👉 Read about the IPageService in the API docs

Set Page Properties

You can set these page properties

  1. SetTitle(newToPrefix)
    SetTitle(newTitle, placeholder)
    see docs
  2. SetDescription(newDescription)
    SetDescription(newDescription, placeholder)
    see docs
  3. SetKeywords(additionalKeywords)
    SetKeywords(additionalKeywords, placeholder)
    see docs
  4. SetBase(url) - see docs

Note that SetTitle, SetDescription and SetKeywords will prepend or append whatever you give them to the existing value, unless you specify a placeholder - in which case that placeholder will be replaced.

Set Http Response Codes

In some cases an App may need to set the page to 404 - so that google doesn't index it. Do this using

  • SetHttpStatus(statusCode, optionalmessage) - see docs

Note: ATM this is Dnn ☢️ only, as Oqtane doesn't render each page at a time - so a status code wouldn't work there (yet).

Add Icons and Icon-Sets like FavIcon

Icons / FavIcons are minor enhancements to a page, but they serve more than just the icon in the browser tab. In many cases they may also have larger images used for tiles and more. Use these two commands to get them working:

  • AddIcon - see docs to add a single icon
  • AddIconSet - see docs to add a bundle of icons for various use cases in one step

Add Custom Headers

Custom headers may be important for JavaScripts running on your page or other special purposes. Set them using these methods:

  • AddToHead(string) - see docs
  • AddToHead(tag) - see docs
  • AddMeta(name, content) - see docs

Add JsonLD Headers (

JsonLD is a powerful way to describe your page to other systems, especially web crawlers like Google. It uses conventions from Use this to add custom JsonLD headers:

  • AddJsonLd(jsonString) - see docs
  • AddJsonLd(jsonObject) - see docs

Add OpenGraph Headers

OpenGraph is a standard to describe your page for Facebook, Twitter and other more social-style systems. It adds meta headers using og: prefixes. Use these commands to add such headers:

  • AddOpenGraph(propertyName, content) - see docs

Activate Page Features

👉 See Page Service to Activate Features & WebResources (JS, CSS, etc.)

Discover More in the Razor Tutorials

We have an rich series of Razor tutorials. You should really check them out 👍.

Activate JavaScript with TurnOn (new v15)

TurnOn is a simple JavaScript helper which allows to you turn on / boot a script when everything it needs has been loaded. You can do this by creating HTML manually, but in v15 we added a simple helper which makes it easier.

  • TurnOn(runCommand) - see docs
  • TurnOn(runCommand, require: object) - see docs
  • TurnOn(runCommand, data: object) - see docs
  • TurnOn(runCommand, require: object, data: object) - see docs
  • TurnOn(turnOnSpecs) - see docs


  1. Introduced in 2sxc 12.02 to replace the previous static implementation using RazorBlade
  2. Enhanced in 12.05