Open Closed

AbpSession.UserId is null ! #217


0
behiunforgiven created

Why AbpSession.UserId is null in my Application layer? I disabled multytenancy!


6 Answer(s)
  • 0
    behiunforgiven created

    this code

    Thread.CurrentPrincipal.Identity.GetUserId()
    

    Returns null and

    Thread.CurrentPrincipal.Identity.IsAuthenticated
    

    is False !

  • 0
    hikalkan created
    Support Team

    It will be null if user did not login or IAbpSession is not implemented (if you're using module-zero, then it's implemented). If Thread.CurrentPrincipal.Identity.IsAuthenticated is false, that shows user not logged in.

  • 0
    behiunforgiven created

    Thank You, but User is logged in and U use module-zero

    I create it from Templates

  • 0
    behiunforgiven created

    I found the problem! The problem is that I want to get Current user Information in NavigationProvider to generate menu items according to user Roles ! and when NavigationProvider Creates menu No user is Logged in.

    So my question changed to this:

    HOW CAN I GENERATE MENU ACCORDING TO USER ROLES?

  • 0
    hikalkan created
    Support Team

    Hi,

    You can not get UserId in NavigationProvider since it's executed once on application startup, independent from users.

    You can use permissions (instead of roles) to authorize menu items. See Navigation document: <a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Navigation">http://www.aspnetboilerplate.com/Pages/ ... Navigation</a>

  • 0
    behiunforgiven created

    <cite>hikalkan: </cite> Hi,

    You can not get UserId in NavigationProvider since it's executed once on application startup, independent from users.

    You can use permissions (instead of roles) to authorize menu items. See Navigation document: <a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Navigation">http://www.aspnetboilerplate.com/Pages/ ... Navigation</a>

    Thank You So Much ! I didn't notice that !

    You Are So Fantastic...