• Basics
  • C# & Razor
  • JavaScript & TS
  • Web API
  • .net API

    Show / Hide Table of Contents

    Interface IPageService

    Make changes to the page - usually from Razor.

    This is cross-platform and works for Dnn and Oqtane (Oqtane WIP).

    This is just the interface. When a system implements it, you can get it through Dependency Injection.

    Example: in 2sxc 12+ you can use

    var page = GetService<ToSic.Sxc.Web.IPageService>()
    page.SetTitle("About 2sxc", "post-placeholder");
    

    ...and then work with the resulting object.

    Namespace: ToSic.Sxc.Web
    Assembly: ToSic.Sxc.dll
    Syntax
    [PublicApi_Stable_ForUseInYourCode]
    public interface IPageService
    Remarks

    Introduced in 2sxc 12.02

    Methods

    | Improve this Doc View Source

    Activate(String[])

    Activate a feature on this page. Still WIP, at the moment the only relevant key can be turnOn

    Declaration
    void Activate(params string[] keys)
    Parameters
    Type Name Description
    System.String[] keys
    | Improve this Doc View Source

    AddIcon(String, String, String, Int32, String)

    Add an Icon header tag to the Page.

    Declaration
    void AddIcon(string path, string doNotRelyOnParameterOrder = "Rule: all params must be named (https://r.2sxc.org/named-params), Example: 'enable: true, version: 10'", string rel = "", int size = 0, string type = null)
    Parameters
    Type Name Description
    System.String path

    Path to the image/icon file

    System.String doNotRelyOnParameterOrder

    This is a dummy parameter to force the developer to name the remaining parameters - like size: 75 etc. This allows us to add more parameters in future without worrying that existing code could break.

    System.String rel

    the rel-text, default is 'icon'. common terms are also 'shortcut icon' or 'apple-touch-icon'

    System.Int32 size

    Will be used in size='#x#' tag; only relevant if you want to provide multiple separate sizes

    System.String type

    An optional type. If not provided, will be auto-detected from known types or remain empty

    | Improve this Doc View Source

    AddIconSet(String, String, Object, IEnumerable<String>, IEnumerable<Int32>)

    Add a set of icons to the page

    Declaration
    void AddIconSet(string path, string doNotRelyOnParameterOrder = "Rule: all params must be named (https://r.2sxc.org/named-params), Example: 'enable: true, version: 10'", object favicon = null, IEnumerable<string> rels = null, IEnumerable<int> sizes = null)
    Parameters
    Type Name Description
    System.String path

    Path to the image/icon file

    System.String doNotRelyOnParameterOrder

    This is a dummy parameter to force the developer to name the remaining parameters - like size: 75 etc. This allows us to add more parameters in future without worrying that existing code could break.

    System.Object favicon

    path to favicon, default is '/favicon.ico'

    System.Collections.Generic.IEnumerable<System.String> rels
    System.Collections.Generic.IEnumerable<System.Int32> sizes
    | Improve this Doc View Source

    AddJsonLd(Object)

    Add a JSON-LD header according https://developers.google.com/search/docs/guides/intro-structured-data

    Declaration
    void AddJsonLd(object jsonObject)
    Parameters
    Type Name Description
    System.Object jsonObject

    A object which will be converted to JSON. We recommend using dictionaries to build the object.

    | Improve this Doc View Source

    AddJsonLd(String)

    Add a JSON-LD header according https://developers.google.com/search/docs/guides/intro-structured-data

    Declaration
    void AddJsonLd(string jsonString)
    Parameters
    Type Name Description
    System.String jsonString

    A prepared JSON string

    | Improve this Doc View Source

    AddMeta(String, String)

    Add a standard meta header tag. You may also want AddOpenGraph or AddJsonLd

    Declaration
    void AddMeta(string name, string content)
    Parameters
    Type Name Description
    System.String name
    System.String content
    | Improve this Doc View Source

    AddOpenGraph(String, String)

    Add an open-graph header according to http://ogp.me/

    Declaration
    void AddOpenGraph(string property, string content)
    Parameters
    Type Name Description
    System.String property

    Open Graph property name, like title or image:width. 'og:' is automatically prefixed if not included

    System.String content

    value of this property

    | Improve this Doc View Source

    AddToHead(String)

    Add a tag to the header of the page Will simply not do anything if an error occurs, like if the page object doesn't exist

    Declaration
    void AddToHead(string tag)
    Parameters
    Type Name Description
    System.String tag
    | Improve this Doc View Source

    AddToHead(TagBase)

    Add a RazorBlade Tag to the headers of the page Will simply not do anything if an error occurs, like if the page object doesn't exist

    Declaration
    void AddToHead(TagBase tag)
    Parameters
    Type Name Description
    ToSic.Razor.Markup.TagBase tag
    | Improve this Doc View Source

    SetBase(String)

    Add a standard base header tag. new in 3.0

    Declaration
    void SetBase(string url = null)
    Parameters
    Type Name Description
    System.String url

    the optional url for the base tag - if null, will try to default to the real url for the current page

    | Improve this Doc View Source

    SetDescription(String, String)

    Set the Page Description. It will either try to replace the placeholder (second parameter) or otherwise prefix it to the existing title.

    Declaration
    void SetDescription(string value, string placeholder = null)
    Parameters
    Type Name Description
    System.String value
    System.String placeholder
    | Improve this Doc View Source

    SetHttpStatus(Int32, String)

    Set the page status code if possible (it will work in DNN, but probably not in Oqtane)

    Declaration
    void SetHttpStatus(int statusCode, string message = null)
    Parameters
    Type Name Description
    System.Int32 statusCode

    An HTTP status code like 404

    System.String message

    Message / Description text (optional) which would be included in the header

    | Improve this Doc View Source

    SetKeywords(String, String)

    Set the Page Keywords. It will either try to replace the placeholder (second parameter) or otherwise prefix it to the existing title.

    Declaration
    void SetKeywords(string value, string placeholder = null)
    Parameters
    Type Name Description
    System.String value
    System.String placeholder
    | Improve this Doc View Source

    SetTitle(String, String)

    Set the Page Title. It will either try to replace the placeholder (second parameter) or otherwise prefix it to the existing title.

    Declaration
    void SetTitle(string value, string placeholder = null)
    Parameters
    Type Name Description
    System.String value
    System.String placeholder
    • Improve this Doc
    • View Source
    Back to top Generated by DocFX