App
Switch to Typed (2sxc 16+) Selected: Dynamic (Razor14 or below)
Work with the Context (Page, Site, etc.)
Whenever you need to know about the current environment, you need Context information. These are the contexts you should know about:
- Platform
- Site
- Page
- Module
- View
- User
With the ICmsContext object you can get general information about the current platform.
On the older Razor14 or Razor12 it's on CmsContext.Platform.
⬇️ Result | Source ➡️
-
.NameCurrent platform name is: Oqtane -
.TypeCurrent platform type is: Oqtane -
.VersionCurrent platform version is: 5.0.2
With this object you can get general information about the culture.
On the new RazorTyped it's on CmsContext.Culture.
⬇️ Result | Source ➡️
-
.CurrentCodeCurrent code culture is: de-de -
.DefaultCodeen-us
With this object you can get general informtion about the current site.
On the older Razor14 or Razor12 it's on CmsContext.Site.
⬇️ Result | Source ➡️
-
.Idof the current site (same asPortalIdin DNN): 13 -
.UrlThe site url with protocol: https://oqt-apps-dev.2sxc.org/razortutorial12 -
.UrlRootThe site url without a protocol: oqt-apps-dev.2sxc.org/razortutorial12
Get information about the page which is the contxt for the currently running code.
On the older Razor14 or Razor12 it's on CmsContext.Page.
⬇️ Result | Source ➡️
-
.Idof the current page: 288 (TabIdin DNN orPage.PageIdin oqtane.) -
.Urlthe page url with protocol: https://oqt-apps-dev.2sxc.org/razortutorial12 -
.Parametersall the url parameters of the pageid=27&tut=code-context&variant=dyn -
.Parameters[name]Access a specific parameter (in this case the parameterc140from the url)
Get information about the module context the code is running in.
On the older Razor14 or Razor12 it's on CmsContext.Module.
⬇️ Result | Source ➡️
-
.Idof the current module: 352
Get information about the user which is currently used by the code.
On the older Razor14 or Razor12 it's on CmsContext.User.
⬇️ Result | Source ➡️
-
.Idof the current user: -1 -
.IsSiteAdminFalse (check if the current user is a site admin) -
.IsContentAdminFalse (check if the current user can edit content) -
.IsSystemAdminFalse (check if the current user is a supe-user)
Get information about the view context.
On the older Razor14 or Razor12 it's on CmsContext.View.
⬇️ Result | Source ➡️
-
.Idof the current view: 47382 -
.Editionof the current view: (Get information about the edition used or return an empty string) -
.Identifierof the view:
An optional identifier which the View configuration can provide. Use this when you want to use the same template but make minor changes based on the View selected (like change the number of columns). Usually you will use either this OR the Settings: -
.Nameof the viewDefault Tutorial Page (new v16)
Name of the view as configured - note that because of i18n it could be different depending on the language. To clearly identify a view, use the Identifier or use Settings: