Umbraco.TypedContent() returns an object of type IPublishedContent - i.e. you can only use this for published content - it uses the cache which only contains published content nodes.
If you want to get access to unpublished nodes then you should use the ContentService. Note, this will hit the DB so should not be used on pages served to visitors but only for admin / backend / updates etc.
var cs = ApplicationContext.Current.Services.ContentService;
IContent unpubNode = cs.GetById(1200);
Use the ContentService with care - it really should only be used used for the CUD of CRUD operations!
As for your other error - this is usually due to a corrupt cache - what version of Umbraco is this?
Oops: this document is published but not in the cache
When i navigate to some pages in the backend i get this error.
Oops: this document is published but not in the cache
When i republish the site nothing changes, and when i try to get an unpublished page by id for example
it breaks the site.
Any ideas why this is happening? there are no errors in the log. And is there another way to access the pages name without crashes the site.
Thanks Dean
Hi Dean,
Umbraco.TypedContent() returns an object of type IPublishedContent - i.e. you can only use this for published content - it uses the cache which only contains published content nodes.
If you want to get access to unpublished nodes then you should use the ContentService. Note, this will hit the DB so should not be used on pages served to visitors but only for admin / backend / updates etc.
Use the ContentService with care - it really should only be used used for the CUD of CRUD operations!
As for your other error - this is usually due to a corrupt cache - what version of Umbraco is this?
HTH
Steve
Thanks Steve, Manually republishing all the pages parents ended up fixing this issue for me. It is version 7.5.3
Being able to grab unpublished pages is unfortunately necessary for me, i only need to see there name so hopefully that wont cause many issues.
Thanks again for your reply.
is working on a reply...