Relatude Help

Writing your own manager

When the built-in options do not fit, write a URL manager. Derive from UrlManagerBase, which brings the whole asset side, signing included, and write the page side:

public class PageUrlManager : UrlManagerBase {
    public override void Initialize(IDataStore store) { … }

    // outbound: the URL of a node, or null when it has none
    public override string? TryGetUrl(NodeMeta meta, bool absolute) { … }

    // inbound: every node this URL could mean, best first
    public override NodeKeyWithCulture[] GetMatches(string completeUrl) { … }

    // may this node have this address?
    public override bool WillAddressResultInUniqueUrl(NodeKey node, Guid cultureId, string address) { … }
}

Security is not the manager's job. GetMatches returns candidates whatever their publication or access, and the store filters them through the QueryContext: that is how one URL shows a draft to an editor and nothing to an anonymous visitor. Tokens are not its job either: files, variants and deeplinks arrive encoded, and the manager only places them.

Optional overrides:

  • GetMatches(completeUrl, nowUtc), which the store calls with the context's time. Override it if you read nodes to match a URL, so a page released by that time (QueryContext.Now) is found.
  • IsOwnUrl(url), which says which URLs in HTML are the site's (§18.2).
  • IUrlManagerBatch, which lets SetAddresses compare a node with its siblings only.