Skip to main content

CmsContext Tutorials

Tutorial Home

Interface ICmsSite

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

The .Id attribute:

The id of the current site (this is the same as PortalId in DNN): 0

  <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>

The .Url attribute:

The the site url with protocol: https://kendev.co

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

The .UrlRoot attribute:

The the site url without a protocol: kendev.co

  <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

<!-- unimportant stuff, hidden -->

Interface ICmsSite With this object you... <!-- unimportant stuff, hidden -->


  <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>



<!-- unimportant stuff, hidden -->