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 am working on a custom HttpHandler for our Umbraco 8 website. The handler is working in general, but I need to add a piece to it that requires access to Umbraco's MemberService and MediaService, and I'm confused about how this should be done.
I updated my handler to inherit from UmbracoHttpHandler, and this looks like it should give it access to the services via Current.Services. When I try to access those object instances directly inside the ProcessRequest method, though, I get an Object reference not set to an instance of an object. error.
Object reference not set to an instance of an object.
I have also tried injecting the services via LightInject, and it looked like instances were getting injected, but I was still getting a null reference exception on MediaService. I was just specifying the desired dependencies in a constructor, but not registering the code as a component or anything; I wasn't sure if that was needed, or how to do it.
Can anyone point me in the right direction?
Going to answer my own question here: after reading https://our.umbraco.com/documentation/Reference/Common-Pitfalls/ again, I see that UmbracoHttpHandler is mentioned as one of the base classes that exposes the services, and that the existing instances should be used instead of DI. I am having an issue with that, but I'm going to make a separate thread to avoid confusion.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted