Unpublish auto redirect

Jay Asbury asked on March 7, 2024 10:07

As seen in https://devnet.kentico.com/questions/redirect-after-a-page-is-unpublished I am seeing same issue however, I have updated nuget packages to match hotfix version.

Nuget package version: 13.0.130

Hotfix: 130

Previous hotfix version: 88

I can provide a url in a private response and Publish Settingsare the publish settings along with the url is a valid page in site.

Recent Answers


Jay Asbury answered on March 7, 2024 11:26

I might have figured it out. What I need is a PublishedOrRedirected query like this that says either published or is unpublished and Redirected. I just need to know how to do that

    public MultiDocumentQuery PublishedOrRedirected(MultiDocumentQuery query)
    {
        return  query...
    }


        public IQueryResult<NavigableItemBase> GetByUrl(string url)
    {
        if (url.StartsWith("/"))
        {
            url = url.Remove(0, 1);
        }

        if (url.IsNullOrWhiteSpace())
        {
            url = PageAlias.Home;
        }

        var query = new MultiDocumentQuery()
            .OnCurrentSite()
            .LatestVersion(_isPreviewEnabled)
            .Published(!_isPreviewEnabled)
            .Culture(_cultureName)
            .Types(_types)
            .WhereEquals(nameof(PageUrlPathInfo.PageUrlPathUrlPath), url.Trim())
            .WithPageUrlPaths()
            .WithCoupledColumns()
            .Columns("DocumentPageBuilderWidgets")
            .TopN(1);
            ...

See how we use .Published to get the only Published documents? What we need is a PublishedOrRedirected query.

0 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on March 7, 2024 11:28

I would start with testing this on a clean, out of the box Kentico installation with the sample Dancing Goat project - to see whether it is a bug in Kentico or the issue is in your front end app (we do not know your front end app code and setup and it is this app which is actually serving the site).
Also, this feature works only with the content tree based routing.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.