Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I recently moved from Umbraco 8 to Umbraco 9 and had to refactor my code to use the IUmbracoContextAccessor more often.
This may be a dumb question, but I wanted to make sure.
When getting an Umbraco context from IUmbracoContextAccessor, should we dispose of it or will it be handled elsewhere at the end of the request life cycle?
Core services like the IUmbracoContextAccessor (but also things like the UmbracoHelper, IPublishedContentQuery, ...) are all based on an HttpRequest, and their lifetime is controlled by it. This also means that they will automatically be disposed of when the request itself ends! The same reason applies for why we cannot inject these services if we are not operating within a request!
Hope this helped!
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted