Copied to clipboard

Flag this post as spam?

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


  • simon eriksen 22 posts 111 karma points
    Nov 05, 2018 @ 13:46
    simon eriksen
    0

    Programmatically save and publish node as if you did it manually

    Hi

    I've got some nodes that while they are published, still gives me a 404 error when viewed in the browser... I've tried to publish with the contentservice like this

    var _contentservice = ApplicationContext.Current.Services.ContentService;
    var node = _contentservice.GetById(4836);
    _contentservice.SaveAndPublishWithStatus(node);
    

    But that doesnt work, neither does republishing this entire site. The only thing that works for me is to manually click in on every single node and press save and publish which is not ideal with how many there are... Thanks in advance

  • Dan Diplo 1505 posts 5911 karma points MVP 4x c-trib
    Nov 05, 2018 @ 14:24
    Dan Diplo
    0

    Can you right click your home page and choose "Publish" from there and then tick the "Publish pagename and all its subpages" ? This allows you to publish all pages at once.

  • simon eriksen 22 posts 111 karma points
    Nov 06, 2018 @ 08:15
    simon eriksen
    0

    Hi Dan

    It Didn't seem to have any effect, pages still 404. I've discovered i can see the page in preview mode.

  • John Bergman 460 posts 1066 karma points
    Nov 06, 2018 @ 18:29
    John Bergman
    0

    Is it possible you have conflicting routes? try deleting the umbraco.config in the app_data folder and restarting iis.

  • Amir Khan 1199 posts 2567 karma points
    Nov 06, 2018 @ 21:55
    Amir Khan
    0

    Are the nodes you want to publish in a folder? I use this to republish tons of location pages periodically, usually if I need to change a template or something.

    var contentService = ApplicationContext.Current.Services.ContentService; var content = contentService.GetChildren(1234); foreach(var contentItem in content) { // do your thing }

  • Paul McCarthy 27 posts 127 karma points
    Nov 06, 2018 @ 22:25
    Paul McCarthy
    0

    Hi Simon I’ve had similar issues and found it to be related to cache problems. Something as simple as rebuilding the internal index and article index worked for me. Also worth completely emptying the site’s recycle bin from time to time...

  • simon eriksen 22 posts 111 karma points
    Nov 07, 2018 @ 12:19
    simon eriksen
    0

    Thanks for the suggestions.

    I did have to do it manually before you posted them, but if the problem comes back I'l try them out.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies