/// <summary> /// Follows external redirection through <c>umbracoRedirect</c> document property. /// </summary> /// <remarks>As per legacy, if the redirect does not work, we just ignore it.</remarks> private void FollowExternalRedirect(IPublishedRequestBuilder request) { if (request.PublishedContent == null) { return; } // don't try to find a redirect if the property doesn't exist if (request.PublishedContent.HasProperty(Constants.Conventions.Content.Redirect) == false) { return; } var redirectId = request.PublishedContent.Value(_publishedValueFallback, Constants.Conventions.Content.Redirect, defaultValue: -1); var redirectUrl = "#"; if (redirectId > 0) { redirectUrl = _publishedUrlProvider.GetUrl(redirectId); } else { // might be a UDI instead of an int Id GuidUdi?redirectUdi = request.PublishedContent.Value <GuidUdi>(_publishedValueFallback, Constants.Conventions.Content.Redirect); if (redirectUdi is not null) { redirectUrl = _publishedUrlProvider.GetUrl(redirectUdi.Guid); } } if (redirectUrl != "#") { request.SetRedirect(redirectUrl); } }