Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Harsheet 71 posts 302 karma points
    Dec 18, 2018 @ 23:54
    Harsheet
    0

    Content url error - This document is published but its url would collide with content (error) - UMBRACO 7.11.1

    Hey guys,

    We we add content one after another consecutively. One of them shows the below error in url -

    This document is published but its url would collide with content (error)

    But we get a proper URL once we refresh the page.

    And just to confirm that we have a custom url implementaion.

    Update - We debugged it more and realize that its the examine search that is sometimes returning null. But the same content works fine on refresh.

    Here is the code-

    Any help would be appreciated.

    public T FindContentByUrlName<T>(string urlName, bool isVideo)
        {
            var searcher = _examineMagProd.GetExamineManagerProviderInstance(SearchType.UrlNameSearch);
            var criteria = searcher.CreateSearchCriteria(IndexTypes.Content);
            var query = criteria.Field("urlName", urlName);
            // For content with video in URL only search in Video Watch Page and for other urls search all Content except Video Watch page
            query = isVideo ? query.And().NodeTypeAlias(VideoPage.ModelTypeAlias) : query.Not().NodeTypeAlias(VideoPage.ModelTypeAlias);
            var filter = query.Compile();
            var node = urlName.Equals("video") && isVideo ? GetRecentlyPublishedVideo()  :  searcher.Search(filter).FirstOrDefault();
            var content = (node == null ? null : _umbracoContext.ContentCache_GetById(node.Id));
            return (T)content;
        }
    

    Thanks in advance

Please Sign in or register to post replies

Write your reply to:

Draft