public object RoutePartial(PageData content, SegmentContext segmentContext)
        {
            if (!_externalReviewOptions.IsEnabled)
            {
                return(null);
            }

            var nextSegment = segmentContext.GetNextValue(segmentContext.RemainingPath);

            if (string.IsNullOrWhiteSpace(nextSegment.Next))
            {
                return(null);
            }

            if (!string.Equals(nextSegment.Next, _externalReviewOptions.ContentPreviewUrl, StringComparison.CurrentCultureIgnoreCase))
            {
                return(null);
            }

            nextSegment = segmentContext.GetNextValue(nextSegment.Remaining);
            var token = nextSegment.Next;

            var externalReviewLink = _externalReviewLinksRepository.GetContentByToken(token);

            if (!externalReviewLink.IsPreviewableLink())
            {
                return(null);
            }

            var contentReference = externalReviewLink.ContentLink;

            if (externalReviewLink.ProjectId.HasValue)
            {
                var contentContentLink = PreviewUrlResolver.IsGenerated(segmentContext.QueryString) ? content.ContentLink : contentReference;
                contentReference         = _projectContentResolver.GetProjectReference(contentContentLink, externalReviewLink.ProjectId.Value);
                ExternalReview.ProjectId = externalReviewLink.ProjectId;
            }

            try
            {
                var page = _contentLoader.Get <IContent>(contentReference);

                // PIN code security check, if user is not authenticated, then redirect to login page
                if (!_externalLinkPinCodeSecurityHandler.UserHasAccessToLink(externalReviewLink))
                {
                    _externalLinkPinCodeSecurityHandler.RedirectToLoginPage(externalReviewLink);
                    return(null);
                }
                segmentContext.RemainingPath = nextSegment.Remaining;
                ExternalReview.Token         = token;

                return(page);
            }
            catch (ContentNotFoundException)
            {
                return(null);
            }
        }
        public object RoutePartial(PageData content, SegmentContext segmentContext)
        {
            if (!_externalReviewOptions.IsEnabled)
            {
                return(null);
            }

            var nextSegment = segmentContext.GetNextValue(segmentContext.RemainingPath);

            if (string.IsNullOrWhiteSpace(nextSegment.Next))
            {
                return(null);
            }

            if (!string.Equals(nextSegment.Next, _externalReviewOptions.ContentPreviewUrl, StringComparison.CurrentCultureIgnoreCase))
            {
                return(null);
            }

            nextSegment = segmentContext.GetNextValue(nextSegment.Remaining);
            var token = nextSegment.Next;

            var externalReviewLink = _externalReviewLinksRepository.GetContentByToken(token);

            if (!externalReviewLink.IsPreviewableLink())
            {
                return(null);
            }

            if (externalReviewLink.VisitorGroups != null)
            {
                System.Web.HttpContext.Current.Items["ImpersonatedVisitorGroupsById"] = externalReviewLink.VisitorGroups;
            }

            var contentReference = externalReviewLink.ContentLink;

            if (externalReviewLink.ProjectId.HasValue)
            {
                var languageID = content.Language.Name;

                var contentContentLink = PreviewUrlResolver.IsGenerated(segmentContext.QueryString) ? content.ContentLink : contentReference;
                contentReference         = _projectContentResolver.GetProjectReference(contentContentLink, externalReviewLink.ProjectId.Value, languageID);
                ExternalReview.ProjectId = externalReviewLink.ProjectId;
            }

            try
            {
                var page = _contentLoader.Get <IContent>(contentReference, content.Language);

                // PIN code security check, if user is not authenticated, then redirect to login page
                if (!_externalLinkPinCodeSecurityHandler.UserHasAccessToLink(externalReviewLink))
                {
                    _externalLinkPinCodeSecurityHandler.RedirectToLoginPage(externalReviewLink);
                    return(null);
                }
                segmentContext.RemainingPath = nextSegment.Remaining;

                // set ContentLink in DataTokens to make IPageRouteHelper working
                segmentContext.RouteData.DataTokens[RoutingConstants.NodeKey] = page.ContentLink;
                ExternalReview.Token = token;

                return(page);
            }
            catch (ContentNotFoundException)
            {
                return(null);
            }
        }