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
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