Skip to content

Instantly share code, notes, and snippets.

@michaelbramwell
Created November 30, 2016 01:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelbramwell/c91679f6948f4ff92e7214a1328fb22b to your computer and use it in GitHub Desktop.
Save michaelbramwell/c91679f6948f4ff92e7214a1328fb22b to your computer and use it in GitHub Desktop.
Sitecore get current site root. ref - http://stackoverflow.com/a/33161150/6264690
Item currentItem = Sitecore.Context.Item;
SiteInfo currentSiteRoot = SiteContextFactory.Sites
.Where(s => s.RootPath != "" && currentItem.Paths.Path.ToLower().StartsWith(s.RootPath.ToLower()))
.OrderByDescending(s => s.RootPath.Length)
.FirstOrDefault();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment