Copied to clipboard

Flag this post as spam?

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


  • Gary Smith 27 posts 47 karma points
    Aug 10, 2010 @ 20:36
    Gary Smith
    0

    ProfileBase not working as expected.

    While playing with the profiles, I have run into a small error, and maybe it's just a little confusion about the key/values for the profile properties, but I get this error: {"The settings property 'zipcode' was not found."}.  Also, the fields I do update are not saved to the database, even though I'm calling save.

    I have a class derived from profile provider

     

    public class NPSProfile : ProfileBase

    {

     

    public static NPSProfile CurrentUser

    {

     

    get

    {

     

    return (NPSProfile)(ProfileBase.Create(Membership.GetUser().UserName));

    }

    }

     

    public static NPSProfile GetUser(string userName)

    {

     

    return (NPSProfile)(ProfileBase.Create(userName));

    }

     

    public string Address

    {

     

    get

    {

     

    return ((string)(base["address"]));

    }

     

    set

    {

     

    base["address"] = value;

    Save();

    }

    }

     

    public string City

    {

     

    get

    {

     

    return ((string)(base["city"]));

    }

     

    set

    {

     

    base["city"] = value;

    Save();

    }

    }

     

    public string State

    {

     

    get

    {

     

    return ((string)(base["state"]));

    }

     

    set

    {

     

    base["state"] = value;

    Save();

    }

    }

     

    public string Zip

    {

     

    get

    {

     

    return ((string)(base["zipcode"]));

    }

     

    set

    {

     

    base["zipcode"] = value;

    Save();

    }

    }

     

    public string Phone

    {

     

    get

    {

     

    return ((string)(base["phone"]));

    }

     

    set

    {

     

    base["phone"] = value;

    Save();

    }

    }

     

     

    }

    That class has the corresponding entry in the web.config

    <

     

    profile defaultProvider="UmbracoMemberProfileProvider" enabled="true" inherits="NPS10x10.Umbraco.Profile.NPSProfile, NPS10x10.Umbraco.Profile">

    <

     

    providers>

    <

     

    clear />

    <

     

    add name="UmbracoMemberProfileProvider" type="umbraco.providers.members.UmbracoProfileProvider, umbraco.providers" />

    </

     

    providers>

    <

     

    properties>

    <

     

    clear />

    <!--

     

    <add name="address" allowAnonymous ="false" provider="UmbracoMemberProfileProvider" type="System.String" />

    <add name="city" allowAnonymous ="false" provider="UmbracoMemberProfileProvider" type="System.String" />

    <add name="state" allowAnonymous ="false" provider="UmbracoMemberProfileProvider" type="System.String" />

    <add name="zip_code" allowAnonymous ="false" provider="UmbracoMemberProfileProvider" type="System.String" />

    <add name="phone" allowAnonymous ="false" provider="UmbracoMemberProfileProvider" type="System.String" />

     

    -->

    </

     

    properties>

    </

     

    profile>

    If I uncomment the add statements, asp.net complains that they already exist.  So I uncomment them.  Then when I need to update the property I do this:

    Profile.

    NPSProfile p = Profile.NPSProfile.GetUser(CreateUserWizard1.UserName);

     

    if (p != null)

    {

    p.Phone =

    "707-555-1212";

    }

    When I inspect p, I find that Zip doesn't exist.  I have the properties in the dashboard for the name to be ZipCode and the underlying file name to be zipcode (pretty much matching the class definition).

     

Please Sign in or register to post replies

Write your reply to:

Draft