I think this is caused because you aren't using the EnsureUmbracoContext in the place where you are using the fields. Therefore, the snapshot has probably been disposed already and cannot be found.
Could you try putting using var _ = _umbracoContextFactory.EnsureUmbracoContext(); before the var rtnEmail = new EmailFields?
Wasn't possible to a get a valid Snapshot
I am getting this error when trying to access content that I have found / retrieved within a global function.. The code is
This seems to work and returns a valid "EmailChildTemplate".
However, where I am using it fails with the error "Wasn't possible to a get a valid Snapshot"
What am I doing wrong?
I think this is caused because you aren't using the EnsureUmbracoContext in the place where you are using the fields. Therefore, the snapshot has probably been disposed already and cannot be found.
Could you try putting
using var _ = _umbracoContextFactory.EnsureUmbracoContext();
before thevar rtnEmail = new EmailFields
?Yes, that fixed it.
I think I wasn't understanding quite what was going on here!! 🙄
is working on a reply...