Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • wilmar 19 posts 129 karma points
    Feb 08, 2021 @ 12:46
    wilmar
    0

    Im getting this weird error when i try to inject UmbracoHelper or MembershipHelper

    enter image description here

    This is my code

        [RuntimeLevel(MinLevel = RuntimeLevel.Run)]
        public class RegisterMediaRouteComposer : IUserComposer
        {
    
    
            public void Compose(Composition composition)
            {
                composition.Components().Append<RegisterMediaRouteComponent>();
            }
        }
    
        public class RegisterMediaRouteComponent : IComponent
        {
    
            IMediaService _mediaService;
            IUmbracoContextFactory _context;
            MembershipHelper _MembershipHelper;
            UmbracoHelper _umbracoHelper;
    
            public RegisterMediaRouteComponent(IMediaService mediaService, IUmbracoContextFactory context,UmbracoHelper umbracoHelper)
            {
                _mediaService = mediaService;
                _context = context;
                _umbracoHelper = umbracoHelper;
    
    
            }
            public void Initialize()
            {
            }
            public void Terminate()
            {
    
            }
        }
    
  • Nik 1614 posts 7260 karma points MVP 7x c-trib
    Feb 08, 2021 @ 13:06
    Nik
    0

    Hi Wilmar,

    Please don't inject those two helpers. They heavily rely on HttpContexts and so will have issues if used outside of the scope of them.

    There are alterative services you can inject so the question becomes, what are you actually trying to do?

    Thanks

    Nik

  • wilmar 19 posts 129 karma points
    Feb 08, 2021 @ 13:45
    wilmar
    0

    Hi I need to read the current logged in member I know that MembershipHelper provides my with that method. do you know other way to acces current member

Please Sign in or register to post replies

Write your reply to:

Draft