#3 CmsContext.Site – Name, URL etc.
Requirements
Resources
Interface ICmsSite
With this object you can get general informtion about the current site.
On the new RazorPro
it's on MyContext.Site
.
On the older Razor14
or Razor12
it's on CmsContext.Site
.
Output
-
.Id
of the current site (same asPortalId
in DNN): 2 -
.Url
The site url with protocol: https://blazor-cms.org/oqtane-tutorials -
.UrlRoot
The site url without a protocol: blazor-cms.org/oqtane-tutorials
#3 CmsContext.Site – Name, URL etc.
Source Code of this file
Below you'll see the source code of the file. Note that we're just showing the main part, and hiding some parts of the file which are not relevant for understanding the essentials. Click to expand the code
@inherits Custom.Hybrid.RazorTyped @using ToSic.Razor.Blade; <!-- unimportant stuff, hidden --> <div @Sys.PageParts.InfoWrapper()> @Html.Partial("../shared/DefaultInfoSection.cshtml") <div @Sys.PageParts.InfoIntro()> <h2>Interface ICmsSite</h2> <p> With this object you can get general informtion about the current site. </p> <p>On the new <code>RazorPro</code> it's on <code>MyContext.Site</code>.</p> <p>On the older <code>Razor14</code> or <code>Razor12</code> it's on <code>CmsContext.Site</code>.</p> </div> </div> <ol> <li> <code>.Id</code> of the current site (same as <code>PortalId</code> in DNN): <strong>@MyContext.Site.Id</strong> </li> <li> <code>.Url</code> The site url with protocol: <strong>@MyContext.Site.Url</strong> </li> <li> <code>.UrlRoot</code> The site url without a protocol: <strong>@MyContext.Site.UrlRoot</strong> </li> </ol> @* Snippet for the old v14 code, which shouldn't run but should be shown. This is a bit of a hack, but it works <ol> <li> <code>.Id</code> of the current site (same as <code>PortalId</code> in DNN): <strong>@CmsContext.Site.Id</strong> </li> <li> <code>.Url</code> The site url with protocol: <strong>@CmsContext.Site.Url</strong> </li> <li> <code>.UrlRoot</code> The site url without a protocol: <strong>@CmsContext.Site.UrlRoot</strong> </li> </ol> *@ @* Footer *@ @Html.Partial("../Shared/Layout/FooterWithSource.cshtml", new { Sys = Sys })