Get IContent as IPublishedContent item
# help-with-umbraco
c
Please can you help me work out how to get an IPublishedContent item from an IContent item without relying on the Umbraco Context?
s
So really just: "an IPublishedContent item without relying on the Umbraco Context"? I don't think that's possible. What are you trying to achieve with that?
c
I did it in the end. Was able to use some code from your blog post where used the service provider and and published content query thing and I was then able to get my item as ipublishedcontent.
s
Isn't that
using var _ = _umbracoContextFactory.EnsureUmbracoContext();
and therefore you still have an Umbraco Context? 😅 I am just wondering if you got away with not getting the context, which seems.. impossible.
c
It only works when I have that line above it even though I’m not using it 🤣
s
Yes, because it constructs a context for you, and you're definitely using it, as it starts with
using
😉
c
It’s weird though because when I tried using it to get content using the Umbraco content cache it didn’t work but the published query thing did work
s
I still don't know what you're trying to do, so can't tell you why you'd need it 🙂