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.
🪒 In Dynamic Razor it's found on CmsContext
🪒 In Typed Razor it's found on MyContext
, but many objects are directly available, eg. MyPage
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 SourceCulture
Information about languages / culture of the current request
Declaration
ICmsCulture Culture { get; }
Property Value
Type | Description |
---|---|
ICmsCulture |
Module
Information about the Module / Container which holds an 2sxc content block in the CMS
Declaration
ICmsModule Module { get; }
Property Value
Type | Description |
---|---|
ICmsModule |
Page
Information about the current Page (called Tab in DNN). It's especially useful to get current URL Parameters.
Declaration
ICmsPage Page { get; }
Property Value
Type | Description |
---|---|
ICmsPage |
Platform
Information about the platform that's currently running.
Declaration
ICmsPlatform Platform { get; }
Property Value
Type | Description |
---|---|
ICmsPlatform |
Site
Information about the Site (called Portal in DNN)
Declaration
ICmsSite Site { get; }
Property Value
Type | Description |
---|---|
ICmsSite |
User
Information about the current user. It's especially useful to see if the user has any kind of Admin privileges.
Declaration
ICmsUser User { get; }
Property Value
Type | Description |
---|---|
ICmsUser |
View
View-information such as the view Name, Identity or Edition.
Declaration
ICmsView View { get; }
Property Value
Type | Description |
---|---|
ICmsView |
Remarks
New in v12.02