Created
November 30, 2016 01:17
-
-
Save michaelbramwell/c91679f6948f4ff92e7214a1328fb22b to your computer and use it in GitHub Desktop.
Sitecore get current site root. ref - http://stackoverflow.com/a/33161150/6264690
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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