Copied to clipboard

Flag this post as spam?

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


  • Allan Svelmøe Hansen 25 posts 136 karma points
    Jan 28, 2022 @ 10:28
    Allan Svelmøe Hansen
    0

    Problem casting to strongly typed member in Umbraco9

    Hi.

    I have a weird one I can't quite identify:

    I have a custom member type called 'Shop Member', and I have a models builder generated class for this ShopMember.

    Then I have the following code:

    var identity = await _memberManager.GetCurrentMemberAsync();
    var shopMember = _memberManager.AsPublishedMember(identity) as ShopMember;
    

    Locally on my dev environment this works completely fine. I get my member identity, I get the published content and I can cast it.

    On the server where it's deployed, I cannot cast to ShopMember (I've tried to do a direct cast as well, and get the invalid cast exception)

    If I don't cast, I can see that the Content Type for my member is my 'Shop Member' content type, and I can access the properties and get the values. I just can't cast it to the strongly typed version.

    If anybody has ideas/experienced something similar, I'd be very glad for information :)

    Thanks in advance.

Please Sign in or register to post replies

Write your reply to:

Draft