Skip to main content
Home  › ... Razor

CmsContext Tutorials

Tutorial HomeCmsContext

Interface ICmsSite

With this object you can get general informtion about the current site.

Output

The .Id attribute:

The id of the current site (this is the same as PortalId in DNN): 24
<h3>The .Id attribute:</h3>
The id of the current site (this is the same as <code>PortalId</code> in DNN): 
<strong>
  @CmsContext.Site.Id
</strong>

Output

The .Url attribute:

The the site url with protocol: https://2sxc.org/dnn-tutorials/en
<h3>The .Url attribute:</h3>
The the site url with protocol:
<strong>
  @CmsContext.Site.Url
</strong>

Output

The .UrlRoot attribute:

The the site url without a protocol: 2sxc.org/dnn-tutorials/en
<h3>The .UrlRoot attribute:</h3>
The the site url without a protocol:
<strong>
  @CmsContext.Site.UrlRoot
</strong>

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.Razor14
@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>
    </div>
  </div>

  <h3>The .Id attribute:</h3>
  The id of the current site (this is the same as <code>PortalId</code> in DNN): 
  <strong>
    @CmsContext.Site.Id
  </strong>


  <h3>The .Url attribute:</h3>
  The the site url with protocol:
  <strong>
    @CmsContext.Site.Url
  </strong>


  <h3>The .UrlRoot attribute:</h3>
  The the site url without a protocol:
  <strong>
    @CmsContext.Site.UrlRoot
  </strong>


@* Footer *@
@Html.Partial("../Shared/Layout/FooterWithSource.cshtml", new { Sys = Sys })