"Cannot access a disposed object. Object name: 'snapshot'" when trying to get content by id
I get this error when I try to get content by id.
This is my code :
using (var cref = _contextFactory.EnsureUmbracoContext())
{
var node = cref.UmbracoContext.Content.GetById(1210);
}
This is the stack trace:at Umbraco.Web.PublishedCache.NuCache.ContentStore.Snapshot.Get(Int32 id) in D:\a\1\s\src\Umbraco.Web\PublishedCache\NuCache\ContentStore.cs:line 1476
at Umbraco.Web.PublishedCache.NuCache.ContentCache.GetById(Boolean preview, Int32 contentId) in D:\a\1\s\src\Umbraco.Web\PublishedCache\NuCache\ContentCache.cs:line 227
at .....
I have an IHttpModule that calls a service, and in that service I have the above lines of code.
_contextFactory is injected in the constructor of the service.
"Cannot access a disposed object. Object name: 'snapshot'" when trying to get content by id
I get this error when I try to get content by id. This is my code :
This is the stack trace:
at Umbraco.Web.PublishedCache.NuCache.ContentStore.Snapshot.Get(Int32 id) in D:\a\1\s\src\Umbraco.Web\PublishedCache\NuCache\ContentStore.cs:line 1476 at Umbraco.Web.PublishedCache.NuCache.ContentCache.GetById(Boolean preview, Int32 contentId) in D:\a\1\s\src\Umbraco.Web\PublishedCache\NuCache\ContentCache.cs:line 227 at .....
I have an IHttpModule that calls a service, and in that service I have the above lines of code.
_contextFactory is injected in the constructor of the service.
I am running Umbraco 8.2.1
What fixed it for me : My HttpModule was put after the Umbraco modules in the Web.config. After moving it above, the issue was fixed.
The assumption is that everything is disposed of after the request goes through the Umbraco modules.
is working on a reply...