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 122 posts 506 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 374 posts 1346 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);
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft