예제 #1
0
        public virtual async Task <SiteContext> ResolveSite(
            string hostName,
            string path,
            CancellationToken cancellationToken = default(CancellationToken)
            )
        {
            var           pathStartingSegment = path.StartingSegment();
            ISiteSettings site = null;

            if (MultiTenantOptions.Mode == MultiTenantMode.FolderName)
            {
                if (string.IsNullOrWhiteSpace(pathStartingSegment))
                {
                    pathStartingSegment = "root";
                }
                site = await SiteQueries.FetchByFolderName(pathStartingSegment, cancellationToken);
            }
            else
            {
                site = await SiteQueries.Fetch(hostName, cancellationToken);
            }

            if (site != null)
            {
                DataProtector.UnProtect(site);
                return(new SiteContext(site));
            }

            return(null);
        }