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
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.
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
}
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...
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.
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.
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
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
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.
Hi Dan
It Didn't seem to have any effect, pages still 404. I've discovered i can see the page in preview mode.
Is it possible you have conflicting routes? try deleting the umbraco.config in the app_data folder and restarting iis.
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 }
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...
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 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?
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
is working on a reply...