I am experiencing a strange intermittent problem with a Custom Profile class that is derived from the ProfileBase class. Under normal circumstances things work well. But if i log in a user, then log out again, then log in as a different user all the PropertyValues
in ProfileBase return nothing, but when i check the ProfileCommon object they are all present.
For example;
public long PartyId
{
get
{
long partyId = 0;
object o = GetPropertyValue("PartyId");
if (o != null)
{
partyId = long.Parse(o.ToString());
}
return partyId;
}
set { SetPropertyValue("PartyId", value); }
}
The GetPropertyValue method returns nothing, but if I set a break point and run this in the Immediate Window, the correct value is returned;
And why you created this custom class ? why you didn't used the ProfileCommon class which is being generated by Visual studio when you set the Profile properties in web.config ...
are you using Web application project ? or web site project ? ( I mean , when you created the site ... did you chose " New website " OR " New Project " ?
what are you trying to accomplish here ? did you set the Profile proerpties in web.config file ?
There is no GetProfile method to override on the ProfileBase class (http://msdn2.microsoft.com/en-us/library/system.web.profile.profilebase_methods.aspx).
I am not using the ProfileCommon class because we do not want all the Properties munged together in the database and also because we are extending the Profile object with a couple of additional methods too.
This is a web app project, and yes the properties are all set correctly in the web.config.
Normally this works perfectly, it only becomes a problem when you log out then log in as a different user.
slumchild
Member
11 Points
9 Posts
ProfileBase -vs- ProfileCommon
Apr 11, 2008 11:20 AM|LINK
Hi,
I am experiencing a strange intermittent problem with a Custom Profile class that is derived from the ProfileBase class. Under normal circumstances things work well. But if i log in a user, then log out again, then log in as a different user all the PropertyValues in ProfileBase return nothing, but when i check the ProfileCommon object they are all present.
For example;
public long PartyId { get { long partyId = 0; object o = GetPropertyValue("PartyId"); if (o != null) { partyId = long.Parse(o.ToString()); } return partyId; } set { SetPropertyValue("PartyId", value); } }The GetPropertyValue method returns nothing, but if I set a break point and run this in the Immediate Window, the correct value is returned;
Has anyone any advice or ideas of how I can check why the ProfileCommon does contain the values, but the ProfileBase doesn't?
Cheers,
slum.
anas
All-Star
73649 Points
7914 Posts
Moderator
Re: ProfileBase -vs- ProfileCommon
Apr 11, 2008 11:47 AM|LINK
Hi
Did you overrides GetProfile method in this custom class ?
somthing like this :
public virtual ProfileCommon GetProfile(string username) { return ((ProfileCommon)(ProfileBase.Create(username))); }slumchild
Member
11 Points
9 Posts
Re: ProfileBase -vs- ProfileCommon
Apr 11, 2008 01:10 PM|LINK
Hi Anas,
Thanks for getting back to me. No I didn't override the GetProfile method, in fact, I don't see GetProfile in the methods of ProfileBase at all.
Cheers.
anas
All-Star
73649 Points
7914 Posts
Moderator
Re: ProfileBase -vs- ProfileCommon
Apr 11, 2008 01:20 PM|LINK
Ah , I see...
Ok try to add it to your custom class ...
And why you created this custom class ? why you didn't used the ProfileCommon class which is being generated by Visual studio when you set the Profile properties in web.config ...
are you using Web application project ? or web site project ? ( I mean , when you created the site ... did you chose " New website " OR " New Project " ?
what are you trying to accomplish here ? did you set the Profile proerpties in web.config file ?
Thanks
slumchild
Member
11 Points
9 Posts
Re: ProfileBase -vs- ProfileCommon
Apr 11, 2008 01:43 PM|LINK
Hi Anas,
There is no GetProfile method to override on the ProfileBase class (http://msdn2.microsoft.com/en-us/library/system.web.profile.profilebase_methods.aspx).
I am not using the ProfileCommon class because we do not want all the Properties munged together in the database and also because we are extending the Profile object with a couple of additional methods too.
This is a web app project, and yes the properties are all set correctly in the web.config.
Normally this works perfectly, it only becomes a problem when you log out then log in as a different user.
Cheers.
anas
All-Star
73649 Points
7914 Posts
Moderator
Re: ProfileBase -vs- ProfileCommon
Apr 14, 2008 04:55 PM|LINK
Hi
I'm not sure why you have this problem ! did you tried to set the Profile AutoSave settigns to false ?
I also found a good blog post that show how to write a profile wrapper class when working with WAP!
please read it : http://weblogs.asp.net/jgalloway/archive/2008/01/19/writing-a-custom-asp-net-profile-class.aspx