Base solution for your next web application
Open Closed

How can I inject CustomSession in AbpNavigationProvider? #1598


User avatar
0
omital created

I have a Custom session called LIMSSession like this

public class LIMSSession : ITransientDependency
    {
        public int? SubsystemId
        {
            get
            {
                var claimsPrincipal = Thread.CurrentPrincipal as ClaimsPrincipal;
                if (claimsPrincipal == null)
                {
                    return null;
                }


                var emailClaim = claimsPrincipal.Claims.FirstOrDefault(c => c.Type == "SubsystemId");
                if (emailClaim == null || string.IsNullOrEmpty(emailClaim.Value))
                {
                    return null;
                }


                return Convert.ToInt32(emailClaim.Value);
            }
        }
    }

SubsystemId initialized after user select current subsystem (after login page) How I can inject LIMSSession to AbpNavigationProvider?


2 Answer(s)
  • User Avatar
    0
    omital created

    I setup navigation provider constructor like this

    public LIMSNavigationProvider(LIMSSession LIMSSession)
            {
                _LIMSSession = LIMSSession;
            }
    

    but SybsystemId always return null?!

  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    Navigation provider only works once the application starts (where there is no session actually). So, you can not create your menus based on the current user. If you want to do that, you can do it just before rendering it in the template.