Copied to clipboard

Flag this post as spam?

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


  • Yannick Smits 321 posts 718 karma points
    Mar 22, 2011 @ 17:04
    Yannick Smits
    0

    Can't access custom Membership properties

    I'm trying to access custom Membership properties but since upgrading to umbaco 4.7 the GenericProperties collections seems to be empty. Anybody else having this?

    Here is my Razor snippet that fails to show the many member properties:

    @using umbraco.cms.businesslogic.property;
    @using umbraco.cms.businesslogic.member;
    
    @{
     var mu = Membership.GetUser("yannicksmits");
     var m = new Member((int)mu.ProviderUserKey);
    }
    <h3>@m.Text</h3>
    
    @foreach (Property p in m.GenericProperties)
    {
        if (!String.IsNullOrEmpty(p.Value.ToString()))
        {
            <p>@p.PropertyType.Alias = @p.Value.ToString()</p>
        }
    }

    also tried it the old way (m.getProperty("propname")) without success.

  • Yannick Smits 321 posts 718 karma points
    Mar 22, 2011 @ 18:11
    Yannick Smits
    0

    And all of a sudden, without changing anything the above snippet started to work?!?!! what is happening here? 

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Mar 22, 2011 @ 18:31
    Sebastiaan Janssen
    0

    I was going to say, this code looks correct. Are you sure the user existed before and that mu.ProviderUserKey was returning a value?

    Maybe it was a weird caching issue, might want to try Start > Run > iisreset  and then immediately load the page with this razor macro on it, maybe you can reproduce it.

  • Winston 4 posts 24 karma points
    Jul 20, 2011 @ 04:37
    Winston
    0

    also have the same problem with my wcf accessing the getProperty method from Member... can somebody help with this?

     

    var member = Member.GetMemberFromLoginAndEncodedPassword("user", @"8alEu4v0ZrvHPaY4LlKDOEo+Rmo=");
    var fullName = member.getProperty("fullName").Value; // CANNOT BE ACCESSED
    var userGroup = member.getProperty("userGroup").Value; // CANNOT BE ACCESSED

     

     

Please Sign in or register to post replies

Write your reply to:

Draft