App


Razor Page Service Tutorials

Tutorial HomeRazer Page Service

Set <base> Tag in Header using the IPageService

This page sets the Base tag in the header. Look at the source of this page to see the result.
There are two ways to do this:

  • Kit.Page.SetBase() will auto-detect the current base. It's extra smart, so the result will also work on the home page of a portal.
  • Kit.Page.SetBase("/some/page") create the base tag with the specified url.

@inherits Custom.Hybrid.RazorTyped

@Kit.Page.SetBase()
@{
  // You can also set a custom base path
  // It's commented out here, as it would affect all the links on the page
  // Kit.Page.SetBase("../");

  // FYI: The output is invisible - it's just a <base> tag in the HTML header
}

Output is Invisible as it only affects the HTML Head

This sample modifies the HTML head, so it's not visible here. 

To see the effect, look at the source in the browser

Kit.Page gets the Page Service on newer Razors

This tutorial inherits from the Custom.Hybrid.Razor14 or the Custom.Hybrid.RazorTyped base class.

This allows us to use Kit.Page to access an IPageService without having to use GetService<IPageService>.