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...
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.
is working on a reply...
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.