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.
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.
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.
Get Key for Member
Hi,
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.
Thanks
I'm getting the same problem.
Seems that keys haven't been added to IPublishedContent yet because it breaks backwards compatibility:
https://github.com/umbraco/Umbraco-CMS/blob/d50e49ad37fd5ca7bad2fd6e8fc994f3408ae70c/src/Umbraco.Core/Models/IPublishedContentWithKey.cs
Maybe the only way we can get the key is by getting an IMember straight from the database:
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.
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?
It's uniqueIdentifier (IIRC) in the umbracoNode table.
In case anyone comes to this issue in Umbraco 8, the below works to get the Guid and Udi of an IPublishedContent:
I don't like manually typing "document", but I can't find a way to get it.
Instead of manually typing the magic string "document" you can use the UdiEntitype and write like this:
is working on a reply...