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 24 posts 113 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 1554 posts 6205 karma points MVP 6x 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 24 posts 113 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 483 posts 1132 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 1287 posts 2744 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 39 posts 160 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 24 posts 113 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.

  • Lars Heesakkers 38 posts 194 karma points
    Mar 21, 2023 @ 03:06
    Lars Heesakkers
    0

    This topic is from quite a few years ago but I have this problem now in my Umbraco 10 website. I migrated from umbraco 7 and it seems that i need to save and publish every node manually to see correct fields in the database (mostly images I think). When i do it programmatically it does not correct itself.

    Does anyone have any suggestions?

  • Gurumurthy 54 posts 127 karma points
    Oct 15, 2023 @ 05:29
    Gurumurthy
    0

    Hi,

    Any suggestions for this, even I have migrated v7 to v12, and some the images into node expecting to manually save and publish to be in cache, there more N number of nodes, publishing all with Descendants make no difference. If I publish manually, its picking image property.

    Tried with IContentService to save and publish still not publishing to cache.

    Any help on this would be highly appreciated!

    Thanks,
    Gurumurthy JV

Please Sign in or register to post replies

Write your reply to:

Draft