Create Profile. Going Crazy. Please, help me out.

S

shapper

Hello,

On my CMS I am signed as administrator and I am creating a Membership
user and its profile:

MembershipCreateStatus status;
MembershipUser user = Membership.CreateUser("Joe", "Pass",
"(e-mail address removed)", null, null, true, null, out status);
if (user != null) {
ProfileHelper profile =
ProfileHelper.GetProfile(user.UserName);
// Define profile properties values here
profile.Save();
}

ProfileHelper is a custom profile provider that has two properties:
Colaborator and Visitor.

When creating the profile I keep getting the error:
System.Configuration.Provider.ProviderException: This property cannot
be set for anonymous users.

But I am creating another user and I am signed with my account. I am
on this for hours and can't solve this!

Could someone, please, help me? Here is my profile provider:

public class ProfileHelper : ProfileBase {
[SettingsAllowAnonymous(false),
SettingsSerializeAs(SettingsSerializeAs.Binary)]
public Profile.Collaborator Collaborator {
get {
return base["Collaborator"] as Profile.Collaborator;
}
set {
base["Collaborator"] = value;
}
} // Collaborator
[SettingsAllowAnonymous(true),
SettingsSerializeAs(SettingsSerializeAs.Binary)]
public Profile.Visitor Visitor {
get {
return base["Visitor"] as Profile.Visitor;
}
set {
base["Visitor"] = value;
}
} // Visitor

// GetProfile
public static ProfileHelper GetProfile() {
return Create(System.Web.Security.Membership.GetUser().UserName)
as ProfileHelper;
} // GetProfile

// GetProfile
public static ProfileHelper GetProfile(string username) {
return Create(username) as ProfileHelper;
} // GetProfile
}

Thanks,

Miguel
 
S

shapper

Hello,

On my CMS I am signed as administrator and I am creating a Membership
user and its profile:

      MembershipCreateStatus status;
      MembershipUser user = Membership.CreateUser("Joe", "Pass",
"(e-mail address removed)", null, null, true, null, out status);
      if (user != null) {
        ProfileHelper profile =
ProfileHelper.GetProfile(user.UserName);
        // Define profile properties values here
        profile.Save();
      }

ProfileHelper is a custom profile provider that has two properties:
Colaborator and Visitor.

When creating the profile I keep getting the error:
System.Configuration.Provider.ProviderException: This property cannot
be set for anonymous users.

But I am creating another user and I am signed with my account. I am
on this for hours and can't solve this!

Could someone, please, help me? Here is my profile provider:

  public class ProfileHelper : ProfileBase {
    [SettingsAllowAnonymous(false),
SettingsSerializeAs(SettingsSerializeAs.Binary)]
    public Profile.Collaborator Collaborator {
      get {
        return base["Collaborator"] as Profile.Collaborator;
      }
      set {
        base["Collaborator"] = value;
      }
    } // Collaborator
    [SettingsAllowAnonymous(true),
SettingsSerializeAs(SettingsSerializeAs.Binary)]
    public Profile.Visitor Visitor {
      get {
        return base["Visitor"] as Profile.Visitor;
      }
      set {
        base["Visitor"] = value;
      }
    } // Visitor

    // GetProfile
    public static ProfileHelper GetProfile() {
      return Create(System.Web.Security.Membership.GetUser().UserName)
as ProfileHelper;
    } // GetProfile

    // GetProfile
    public static ProfileHelper GetProfile(string username) {
      return Create(username) as ProfileHelper;
    } // GetProfile
  }

Thanks,

Miguel

Please, anyone?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top