Copied to clipboard

Flag this post as spam?

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


  • Tom Bruce 121 posts 505 karma points
    Aug 10, 2017 @ 12:25
    Tom Bruce
    0

    How to get UserId - Membership

    Hi folks, how do you get the userId, I have tried the following but receiving an error

    Cannot convert method group ‘GetUserTypeById to non-delegate typeIUser

    public void GetuserId()
        {
            var userTicket = new System.Web.HttpContextWrapper(System.Web.HttpContext.Current).GetUmbracoAuthTicket();
    
    
            if (userTicket != null)
            {
                isLoggedInUser = true;
                IUser currentUser = ApplicationContext.Services.UserService.GetUserTypeById;
            }
    
        }
    
  • Marcio Goularte 356 posts 1248 karma points
    Aug 10, 2017 @ 14:24
    Marcio Goularte
    100

    This method returns a User Type and not a User. Try this:

    var userTicket = new System.Web.HttpContextWrapper(System.Web.HttpContext.Current).GetUmbracoAuthTicket();
    if (userTicket != null) {     
     var currentUser = ApplicationContext.Services.UserService.GetByUsername(userTicket.Name);
    }
    
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies