• Basics
  • Abyss
  • Web APIs
  • C# & Razor
  • .net API
  • JS & TS API

    Show / Hide Table of Contents

    Interface ICmsContext

    This is the runtime context of your code in the CMS. It can tell you about the site, page, module etc. that you're on. Note that it it Platform Agnostic so it's the same on Dnn, Oqtane etc.

    CMS Context in your Code

    All your Razor and WebApi code will have a property CmsContext which provides you information about the environment you're running in.

    Here's a Code Snippet for Razor, showing you what page etc. your code is running on:

    
    ModuleId: @CmsContext.Module.Id
    

    History

    • Added in 2sxc 11.11
    Namespace: ToSic.Sxc.Context
    Assembly: ToSic.Sxc.dll
    Syntax
    [PublicApi]
    public interface ICmsContext

    Properties

    | Improve this Doc View Source

    Culture

    Information about languages / culture of the current request

    Declaration
    ICmsCulture Culture { get; }
    Property Value
    Type Description
    ICmsCulture
    | Improve this Doc View Source

    Module

    Information about the Module / Container which holds an 2sxc content block in the CMS

    Declaration
    ICmsModule Module { get; }
    Property Value
    Type Description
    ICmsModule
    | Improve this Doc View Source

    Page

    Information about the Page (called Tab in DNN)

    Declaration
    ICmsPage Page { get; }
    Property Value
    Type Description
    ICmsPage
    | Improve this Doc View Source

    Platform

    Information about the platform that's currently running.

    Declaration
    ICmsPlatform Platform { get; }
    Property Value
    Type Description
    ICmsPlatform
    | Improve this Doc View Source

    Site

    Information about the Site (called Portal in DNN)

    Declaration
    ICmsSite Site { get; }
    Property Value
    Type Description
    ICmsSite
    | Improve this Doc View Source

    User

    Information about the current user

    Declaration
    ICmsUser User { get; }
    Property Value
    Type Description
    ICmsUser
    | Improve this Doc View Source

    View

    Experimental feature for 12.02 - not final. Provides View-information.

    Declaration
    ICmsView View { get; }
    Property Value
    Type Description
    ICmsView
    Remarks

    New in v12.02, WIP

    • Improve this Doc
    • View Source
    Back to top Generated by DocFX