Imagine being paid to improve your favorite CMS!

It could be you! Umbraco HQ are hiring and are looking for both talents and senior developers. Wonderful workplace, friendly colleagues and competitive salary.

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 53 posts 263 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 185 posts 564 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