Copied to clipboard

Flag this post as spam?

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


  • Marianne Hildesheim Bertelsen 26 posts 169 karma points
    Sep 16, 2014 @ 16:25
    Marianne Hildesheim Bertelsen
    0

    Using UmbracoMemberProfileProvider in stand-alone ASP.NET MVC site

    I'm trying to use Umbraco's Member functionality in a stand-alone ASP.NET MVC site. I've included the dlls from Umbraco 6.1.6 in the MVC project.

    It works fine as long as I use the Members functionality for validating and logging in users on my MVC site.

    But when I want to get and set the custom properties on my MemberType, I can't seem to get access to those.

    My web.config for the MVC site looks like this:

        <profile defaultProvider="UmbracoMemberProfileProvider" enabled="true" inherits="Business.Providers.MemberProfile">
          <providers>
            <clear />
            <add name="UmbracoMemberProfileProvider" type="umbraco.providers.members.UmbracoProfileProvider, umbraco.providers" />
          </providers>
        </profile>
        <membership defaultProvider="CustomMemberProvider" userIsOnlineTimeWindow="15">
          <providers>
            <clear />
            <add name="CustomMemberProvider" type="Business.Providers.CustomMemberProvider" enablePasswordRetrieval="false" enablePasswordReset="false" requiresQuestionAndAnswer="false" defaultMemberTypeAlias="Ekspert" passwordFormat="Hashed" />
          </providers>
        </membership>
        <roleManager enabled="true" defaultProvider="UmbracoRoleProvider">
          <providers>
            <clear />
            <add name="UmbracoRoleProvider" type="umbraco.providers.members.UmbracoRoleProvider" />
          </providers>

     

    My ProfileProvider has (among others) the following getter and setter:

            [SettingsAllowAnonymous(false)]
            public string description
            {
                get
                {
                    var o = base.GetPropertyValue("description");
                    if (o == DBNull.Value)
                    {
                        return string.Empty;
                    }
                    return (string)o;
                }
                set
                {
                    base.SetPropertyValue("description", value);
                }
            }

     

    The custom Umbraco property alias is called "description" (in that casing). When I try to get the Profile for an Umbraco member of type "Ekspert", the decription method throws a NullReferenceException. I try to get the profile like this in my MVC controller (MemberProfile is my custom profile class):

    MemberProfile mp = MemberProfile.GetUserProfile("myUser")

     

    Also, I get the same profile from this call, whether the supplied username exists in Umbraco or not, indicating that some basic setting/connection to Umbraco is missing.

     

    Does it have something to do with my controller not inheriting from UmbracoController and thus not having an UmbracoContext? 

Please Sign in or register to post replies

Write your reply to:

Draft