Table of Contents

Namespace ToSic.Sxc.Context

Context information for the current request / scenario.

The Context gives your code information about the page / site / module etc. it's currently running in. All your code (Razor, WebApi) will have a property CmsContext which is of type ICmsContext.

Note

Your code will always have these objects, but they may sometimes be referencing unknown information. For example, if the current context doesn't have a known Module (like in API scenarios) then CmsContext.Module will return a valid object, but the ID will be < 0.

Interfaces

ICmsBlock

Information about the block - similar to a module. The block is the 2sxc-internal definition of a unit of content. In most cases each module has one block, but there are edge cases such as:

  • modules which show the same block - different module-id, same block-id
  • modules showing multiple blocks such as inner-content.
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.

🪒 In Dynamic Razor it's found on CmsContext
🪒 In Typed Razor it's found on MyContext, but many objects are directly available, like MyPage

ICmsCulture

Information about the cultures/languages used.

🪒 In Dynamic Razor it's found on CmsContext.Culture
🪒 In Typed Razor it's found on MyContext.Culture

ICmsModule

Information about the module context the code is running in.

🪒 In Dynamic Razor it's found on CmsContext.Module
🪒 In Typed Razor it's found on MyContext.Module

ICmsPage

Information about the page which is the context for the currently running code.

🪒 In Dynamic Razor it's found on CmsContext.Page
🪒 In Typed Razor it's found on MyPage

ICmsPlatform

General platform information

🪒 In Dynamic Razor it's found on CmsContext.Platform
🪒 In Typed Razor it's found on MyContext.Platform

ICmsSite

The site context of the code - so basically which website / portal it's running on.

🪒 In Dynamic Razor it's found on CmsContext.Site
🪒 In Typed Razor it's found on MyContext.Site

ICmsUser

The user context of your code - so it's information about the user your code is using.

🪒 In Dynamic Razor it's found on CmsContext.User
🪒 In Typed Razor it's found on MyUser

ICmsView

View context information.

🪒 In Dynamic Razor it's found on CmsContext.View
🪒 In Typed Razor it's found on MyView

ICmsView<TSettings, TResources>

Special Views for strongly typed code. It supplies the Settings and Resources as strongly typed objects.

IParameters

Collection of url parameters of the current page

Note: Has a special ToString() implementation, which gives you the parameters for re-use in other scenarios.

🪒 In Dynamic Razor it's found on CmsContext.Page.Parameters
🪒 In Typed Razor it's found on MyPage.Parameters

Enums

PlatformType

The types of platforms which 2sxc could be running on