Copied to clipboard

Flag this post as spam?

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

  • Wil Jones 11 posts 31 karma points
    Aug 27, 2015 @ 11:35
    Wil Jones

    Get Key for Member


    I have an edit profile page where I'm populating the profile fields, (email, name, etc) from a Web API service I've created which looks up the member by the Id.

    EG /Umbraco/Api/MemberGetProperties/GetMemberProperties?id=2488

    But this is not secure, you could get at Id's and get data returned.

    I can see that a member has a unique key associated with it, and I can get the member from the GetByKey() method.

    But how to I get the Key in the first place? I want to use this in the url.

    In the backoffice this key is used, but I can't find how this is output.


  • Harvey 28 posts 122 karma points
    Mar 22, 2016 @ 10:34

    I'm getting the same problem.

    Seems that keys haven't been added to IPublishedContent yet because it breaks backwards compatibility:

    Maybe the only way we can get the key is by getting an IMember straight from the database:

    var MemberService = UmbracoContext.Current.Application.Services.MemberService;
    var memberId = 1234;
    var iMember = MemberService.GetById(memberId);
    var key = iMember.Key;

    We should be able to use the GetKey() when Umbraco 8 comes. I have heard that Umbraco 8 is reimplementing the database cache, so I guess that keys will be added properly then.

  • Ayo Adesina 429 posts 1022 karma points
    Jan 26, 2017 @ 10:32
    Ayo Adesina

    I'm doing some work with iMember.Key value which is a GUID, so just out of curiosity where is this value stored in the db...

    I opened my umbraco Db.. looked in pretty much every table and I can't find it...

    Can anyone shed any light on this?

  • Geoff Beaumont 75 posts 104 karma points
    Feb 20, 2018 @ 11:48
    Geoff Beaumont

    It's uniqueIdentifier (IIRC) in the umbracoNode table.

  • Jonathon Cove 25 posts 100 karma points
    Mar 03, 2020 @ 15:44
    Jonathon Cove

    In case anyone comes to this issue in Umbraco 8, the below works to get the Guid and Udi of an IPublishedContent:

    using Umbraco.Core;    
    var publishedCont = Umbraco.ContentAtRoot().First(); //Where Umbraco is the UmbracoHelper
    var key = publishedCont.Key;
    var udi = Udi.Create("document", key); //either a document, media or member

    I don't like manually typing "document", but I can't find a way to get it.

  • Rodolphe Toots 29 posts 130 karma points
    Mar 22, 2020 @ 11:03
    Rodolphe Toots

    Instead of manually typing the magic string "document" you can use the UdiEntitype and write like this:

     Udi.Create(UdiEntityType.Document, key)
Please Sign in or register to post replies

Write your reply to: