Still Profile Problems

S

shapper

Hello,

I have the following class to be used in profile:

<Serializable()> _
Public Class Options
Inherits ProfileBase

Private _Newsletter As Boolean
Public Property Newsletter() As Boolean
Get
Return _Newsletter
End Get
Set(ByVal value As Boolean)
_Newsletter = value
End Set
End Property ' Newsletter

End Class ' Options

And in Web.Config I have:

<add allowAnonymous="false" name="Options" type="Options"
serializeAs="Binary"/>

I am getting the following error:

Type 'System.Web.Profile.ProfileBase' in Assembly 'System.Web,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is
not marked as serializable.

Why do I get this error?

I thought when creating profile classes that I should always use
<Serializable()>.

Thanks,

Miguel
 
S

shapper

Hi,

I read this good article and I understood a few more things:
http://aspalliance.com/731

The problem is that I created 5 different classes:
Options, Personal, Settings, Publications and Collaborator.

Each class have various properties and methods.

And is it really needed to add the properties on web.config?

<profile enabled="true" inherits="Options">
<properties>
<add name="Newsletter" type="System.Boolean"/>
</properties>
</profile>

But I can't make this for all the 5 classes I have.
Should I place all the 5 classes inside a new class which would inherit
from ProfileBase?
This class would be the one to be placed in the Web.Config.

Another option is to make all 5 classes as <Serializable()> and add
them to Web.Config as properties.
In this case they will not inherit from ProfileBase.

Finally, I could place all properties (from 5 classes) inside the same
class.
The problem is that only a part of those properties are needed to
anonymous users so I would have a lot of not used properties.

By the way, one of the thing I will need is to search for all users in
profile which subscribe the newsletter.
This is an example of a feature which I will need.

Could you advice me on the way to go?

Thanks,
Miguel
 

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,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top