470,833 Members | 1,251 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,833 developers. It's quick & easy.

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

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",
"Jo*@email.com", 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().Us erName)
as ProfileHelper;
} // GetProfile

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

Thanks,

Miguel

Oct 31 '08 #1
1 2545
On Oct 31, 11:46*pm, shapper <mdmo...@gmail.comwrote:
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",
"J...@email.com", 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().Us erName)
as ProfileHelper;
* * } // GetProfile

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

Thanks,

Miguel
Please, anyone?
Nov 3 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Keith Jakobs, MCP | last post: by
reply views Thread by Ron | last post: by
1 post views Thread by shapper | last post: by
2 posts views Thread by Brandon Holliday | last post: by
4 posts views Thread by Scott M. | last post: by
6 posts views Thread by Mr. X. | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.