Question

I have an issue with an ASP.NET profile implementation. This is my profile code:

public class UserProfile: ProfileBase
{
    public static void Get()
    {
        return (UserProfile)Create(Membership.GetUser().UserName);   
    }
    public static void Get(string username)
    {
        return (UserProfile)Create(username);
    }

    //this property works
    [SettingsAllowAnonymous(false)]
    public string FirstName
    {
        get{ return base.GetProperty("FirstName") as String; }
        set{ base.SetPropertyValue("FirstName", value); }
    }

    //this property works
    [SettingsAllowAnonymous(false)]
    public string LastName
    {
        get{ return base.GetProperty("LastName") as String; }
        set{ base.SetPropertyValue("LastName", value); }
    }

    //this property throws "The settings property 'Email' was not found." error.
    [SettingsAllowAnonymous(false)]
    public string EmailAddress
    {
        get{ return base.GetProperty("Email") as String; }
        set{ base.SetPropertyValue("Email", value); }
    }

    //this property throws "The settings property 'Telephone' was not found." error.
    [SettingsAllowAnonymous(false)]
    public string TelephoneNumber
    {
        get{ return base.GetProperty("Telephone") as String; }
        set{ base.SetPropertyValue("Telephone", value); }
    }
}

My web config looks like this:

<profile inherits="UserProfile" defaultProvider="SqlProfileProvider">
    <providers>
        <add 
            name="SqlProfileProvider" 
            type="System.Web.Profile.SqlProfileProvider"
            connectionStringName="Profile" 
            applicationName="Management" />
    </providers>
</profile>

For some reason when the code executes and I retrieve or update a profile for the current user it blows up. However, what is more curious is that the FirstName and LastName properties work fine. The errors only occur when accessing/updating the the EmailAddress and TelephoneNumber properties.

If I add the <properties> section in the web.config profile section for the FirstName, LastName, EmailAddress, and TelephoneNumber properties a different type of error shows up - "Property is already defined" or something along the lines...

Any ideas on how to fix this? Also you need to know that the back-end for the profile system is SQL Azure, while the front-end is an Azure WCF service.

Thanks,

<bleepzter/>
Was it helpful?

Solution

Are you sure you are matching your field names with the property names? Email != EmailAddress && Telephone != TelephoneNumber

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top