473,574 Members | 3,149 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Profile or Custom Class How to migrate to ASP.NEt 2.0

Hi
I am working on application that need to hold custom user information - Last
and first name, email, some other domain related information.
I used to create Base class for all my pages. The base class would have
CurrentUser property that would hold customer class in session and that was
fine for all my situations.

Now ASP.NET 2.0 came and we have Profile property for pages that could be
extended with configuration to have custom properties - cool. Also looks
like ( I am really just starting with 2.0) a lot of functionality uses
Profile.

So what do I do now with all my custom information about users? Should I
configure Profile to have needed me properties and populate them on log in -
no reference to Custom class or I create property with my custom class for
Profile?

Did anybody did this? What is done in scenario when you need to hold custom
user information in session for ASP.NET 2.0?
(I understand that both ways will work. But if I want to use new features
seems to me that I have to employ Profile. So I can't figure out how to use
it in my scenario)

Thank you,
Shimon
Nov 20 '05 #1
6 2213
At first, I figured it would be better to wrap the profile and session under
one user class to maintain app compatibility in scenarios like this. And
for backwards compatibility and abstraction, there are advantages to
abstracting profile and session into a single user class. However,
ultimately, you will still need to use the profile and session to take full
advantage of the GridView-DataSourceContr ol relationship (they are designed
to pull values from Form, Session, Profile, QueryString, and one or two
other state storage areas), so it's best to store the custom data with the
profile in the underlying impelmentation
Nov 20 '05 #2
Thanks for Keith's detailed input.

Hi Shimon,

Welcome to ASPNET newsgroup.
Regarding on the scenario you mentioned, I'm not sure whether your original
web application is using Froms Authentication and then associate the
Session-Data with each authenticated(l ogin ) user. in ASP.NET 2.0 the
profile service can help store some user specific data, and the user will
be the current User of the ASP.NET request, so if you're using
FormsAuthentica tion(and the corresponding membership service in asp.net
2.0), we can make use of the Profile service to store such data. So each
authenticated user will be associated to his own custom datas. Also, in
asp.net 2.0 we can also turn on anonymous:

<system.web>
<anonymousIdent ification enabled="true" />
...........

so that anonymous (unauthenticate d) user can also have such user specific
data (through an anonymous user id), and this is just some what like a id
associcated with a client session( maintained by cookie....). So the
first thing here is make sure the "User" concept here matchs the one in
your original asp.net 1.1 application, if so, I think we can migrate to use
ASP.NET 2.0 profile services well. Otherwise, we may need to do some
changes ....

As for storing custom data in ASP.NET 2.0 profile service, that's also
quite easy, we just need to define our custom class and the simplest
approach is to mark it as [Serializable], e.g:
=============== ==========
[Serializable]
public class MyUnit
{
public string Name = string.Empty;
public int Count =0;
public bool Enabled = false;
}
=============== ===========
and then, we just need to declare it in the web.config as below:

<system.web>
<profile enabled="true" automaticSaveEn abled="true" >
<properties >
<add name="MyUnit" readOnly="false "
type="CustomPro fileClasses.MyU nit" serializeAs="Bi nary"/>
............... ............

#note that we use "serilizeAs='Bi nary'" because we have mark the class as
"Serializab le"

Then, we can just access that profile property in page code like:

Page_load
{
Profile.MyUnit. Count = 3;
Profile.MyUnit. Name = "fdfda";
}
If there're any other ideas or questions, please feel free to post here.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


--------------------
| From: "Keith Patrick" <ri************ *******@nospam. hotmail.com>
| References: <OU************ **@TK2MSFTNGP10 .phx.gbl>
| Subject: Re: Profile or Custom Class How to migrate to ASP.NEt 2.0
| Date: Thu, 17 Nov 2005 20:14:16 -0600
| Lines: 11
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| X-RFC2646: Format=Flowed; Response
| Message-ID: <OC************ **@TK2MSFTNGP14 .phx.gbl>
| Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| NNTP-Posting-Host: cpe-24-175-26-193.houston.res .rr.com 24.175.26.193
| Path: TK2MSFTNGXA02.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP14.phx. gbl
| Xref: TK2MSFTNGXA02.p hx.gbl
microsoft.publi c.dotnet.framew ork.aspnet:3591 00
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
|
| At first, I figured it would be better to wrap the profile and session
under
| one user class to maintain app compatibility in scenarios like this. And
| for backwards compatibility and abstraction, there are advantages to
| abstracting profile and session into a single user class. However,
| ultimately, you will still need to use the profile and session to take
full
| advantage of the GridView-DataSourceContr ol relationship (they are
designed
| to pull values from Form, Session, Profile, QueryString, and one or two
| other state storage areas), so it's best to store the custom data with
the
| profile in the underlying impelmentation
|
|
|

Nov 20 '05 #3
So let me see if I understood you right.
I have class like this
public class Employee
{
public string LastName{get{.. .}set{...}}
public string FirstName{get{. ..}set{...}}
public string Email{get{...}s et{...}}
public int Id{get{...}set{ ...}}
}

So I will change config file for something like this
<profile enabled="true">
<properties>
<add name = "LastName" type="string"/>
<add name = "FirstName" type="string"/>
<add name = "Email" type="string"/>
<add name = "Id" type="int"/>

</properties>
</profile>

I don't need to save anything I just want to keep user information available
for processing.

Then I will need to implement MembershipProvi der, don't I?

And that's it.
Correct?
Shimon.
"Steven Cheng[MSFT]" <st*****@online .microsoft.com> wrote in message
news:KB******** ******@TK2MSFTN GXA02.phx.gbl.. .
Thanks for Keith's detailed input.

Hi Shimon,

Welcome to ASPNET newsgroup.
Regarding on the scenario you mentioned, I'm not sure whether your
original
web application is using Froms Authentication and then associate the
Session-Data with each authenticated(l ogin ) user. in ASP.NET 2.0 the
profile service can help store some user specific data, and the user will
be the current User of the ASP.NET request, so if you're using
FormsAuthentica tion(and the corresponding membership service in asp.net
2.0), we can make use of the Profile service to store such data. So each
authenticated user will be associated to his own custom datas. Also, in
asp.net 2.0 we can also turn on anonymous:

<system.web>
<anonymousIdent ification enabled="true" />
..........

so that anonymous (unauthenticate d) user can also have such user specific
data (through an anonymous user id), and this is just some what like a id
associcated with a client session( maintained by cookie....). So the
first thing here is make sure the "User" concept here matchs the one in
your original asp.net 1.1 application, if so, I think we can migrate to
use
ASP.NET 2.0 profile services well. Otherwise, we may need to do some
changes ....

As for storing custom data in ASP.NET 2.0 profile service, that's also
quite easy, we just need to define our custom class and the simplest
approach is to mark it as [Serializable], e.g:
=============== ==========
[Serializable]
public class MyUnit
{
public string Name = string.Empty;
public int Count =0;
public bool Enabled = false;
}
=============== ===========
and then, we just need to declare it in the web.config as below:

<system.web>
<profile enabled="true" automaticSaveEn abled="true" >
<properties >
<add name="MyUnit" readOnly="false "
type="CustomPro fileClasses.MyU nit" serializeAs="Bi nary"/>
............... ...........

#note that we use "serilizeAs='Bi nary'" because we have mark the class as
"Serializab le"

Then, we can just access that profile property in page code like:

Page_load
{
Profile.MyUnit. Count = 3;
Profile.MyUnit. Name = "fdfda";
}
If there're any other ideas or questions, please feel free to post here.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


--------------------
| From: "Keith Patrick" <ri************ *******@nospam. hotmail.com>
| References: <OU************ **@TK2MSFTNGP10 .phx.gbl>
| Subject: Re: Profile or Custom Class How to migrate to ASP.NEt 2.0
| Date: Thu, 17 Nov 2005 20:14:16 -0600
| Lines: 11
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| X-RFC2646: Format=Flowed; Response
| Message-ID: <OC************ **@TK2MSFTNGP14 .phx.gbl>
| Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| NNTP-Posting-Host: cpe-24-175-26-193.houston.res .rr.com 24.175.26.193
| Path: TK2MSFTNGXA02.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP14.phx. gbl
| Xref: TK2MSFTNGXA02.p hx.gbl
microsoft.publi c.dotnet.framew ork.aspnet:3591 00
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
|
| At first, I figured it would be better to wrap the profile and session
under
| one user class to maintain app compatibility in scenarios like this.
And
| for backwards compatibility and abstraction, there are advantages to
| abstracting profile and session into a single user class. However,
| ultimately, you will still need to use the profile and session to take
full
| advantage of the GridView-DataSourceContr ol relationship (they are
designed
| to pull values from Form, Session, Profile, QueryString, and one or two
| other state storage areas), so it's best to store the custom data with
the
| profile in the underlying impelmentation
|
|
|

Nov 20 '05 #4
Hi Shimon,

Thanks for your response. Regarding on your further questions:

=============== ===
I have class like this
public class Employee
{
public string LastName{get{.. .}set{...}}
public string FirstName{get{. ..}set{...}}
public string Email{get{...}s et{...}}
public int Id{get{...}set{ ...}}
}

So I will change config file for something like this
<profile enabled="true">
<properties>
<add name = "LastName" type="string"/>
<add name = "FirstName" type="string"/>
<add name = "Email" type="string"/>
<add name = "Id" type="int"/>

</properties>
</profile>
=============== ======

Not exactly, actually, we should mark the custom class with [Serializable]
attribute as below:

[Serializable]
public class Employee
{ ............}
Then, in web.config, we can config it as following:

<profile enabled="true">
<properties>
<add name = "EmployeeIn fo" type="OurNamesp ace.Employee"
serializeAs="Bi nary" />
</properties>
</profile>

Then, we can reference that Profile property in code like:

void Page_Load(....)
{
string firstname = Profile.Employe eInfo.FirstName ;
............
}
If we directly define the "FirstName" , "LastName" ... as Profile
properties like:

<profile enabled="true">
<properties>
<add name = "LastName" type="string"/>
<add name = "FirstName" type="string"/>
............... .....
We can use them as following:

void Page_Load(....)
{
string firstname = Profile.FirstNa me;
string lastname = Profile.LastNam e;
............
}


=============== ==
Then I will need to implement MembershipProvi der, don't I?
=============== ===

Yes, you can implement your custom MembershipProvi der. However, ASP.NET 2.0
has provided SqlServer membership provider which can help store user
account info in sqlserver database (or SQLExpress), does this build-in
provider meet your requirement? Also, the default Provider for Profile
Services is also SQLserver provider(using SQlExpress database...)

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

I don't need to save anything I just want to keep user information
available
for processing.

Then I will need to implement MembershipProvi der, don't I?
--------------------
| From: "Shimon Sim" <sh**********@c ommunity.nospam >
| References: <OU************ **@TK2MSFTNGP10 .phx.gbl>
<OC************ **@TK2MSFTNGP14 .phx.gbl>
<KB************ **@TK2MSFTNGXA0 2.phx.gbl>
| Subject: Re: Profile or Custom Class How to migrate to ASP.NEt 2.0
| Date: Fri, 18 Nov 2005 08:39:22 -0500
| Lines: 154
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| X-RFC2646: Format=Flowed; Original
| Message-ID: <#p************ **@TK2MSFTNGP09 .phx.gbl>
| Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| NNTP-Posting-Host: ool-44c05922.dyn.op tonline.net 68.192.89.34
| Path: TK2MSFTNGXA02.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP09.phx. gbl
| Xref: TK2MSFTNGXA02.p hx.gbl
microsoft.publi c.dotnet.framew ork.aspnet:3592 07
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
|
| So let me see if I understood you right.
| I have class like this
| public class Employee
| {
| public string LastName{get{.. .}set{...}}
| public string FirstName{get{. ..}set{...}}
| public string Email{get{...}s et{...}}
| public int Id{get{...}set{ ...}}
| }
|
| So I will change config file for something like this
| <profile enabled="true">
| <properties>
| <add name = "LastName" type="string"/>
| <add name = "FirstName" type="string"/>
| <add name = "Email" type="string"/>
| <add name = "Id" type="int"/>
|
| </properties>
| </profile>
|
| I don't need to save anything I just want to keep user information
available
| for processing.
|
| Then I will need to implement MembershipProvi der, don't I?
|
| And that's it.
| Correct?
| Shimon.
|
|
| "Steven Cheng[MSFT]" <st*****@online .microsoft.com> wrote in message
| news:KB******** ******@TK2MSFTN GXA02.phx.gbl.. .
| > Thanks for Keith's detailed input.
| >
| > Hi Shimon,
| >
| > Welcome to ASPNET newsgroup.
| > Regarding on the scenario you mentioned, I'm not sure whether your
| > original
| > web application is using Froms Authentication and then associate the
| > Session-Data with each authenticated(l ogin ) user. in ASP.NET 2.0 the
| > profile service can help store some user specific data, and the user
will
| > be the current User of the ASP.NET request, so if you're using
| > FormsAuthentica tion(and the corresponding membership service in asp.net
| > 2.0), we can make use of the Profile service to store such data. So
each
| > authenticated user will be associated to his own custom datas. Also, in
| > asp.net 2.0 we can also turn on anonymous:
| >
| > <system.web>
| > <anonymousIdent ification enabled="true" />
| > ..........
| >
| > so that anonymous (unauthenticate d) user can also have such user
specific
| > data (through an anonymous user id), and this is just some what like a
id
| > associcated with a client session( maintained by cookie....). So the
| > first thing here is make sure the "User" concept here matchs the one in
| > your original asp.net 1.1 application, if so, I think we can migrate to
| > use
| > ASP.NET 2.0 profile services well. Otherwise, we may need to do some
| > changes ....
| >
| > As for storing custom data in ASP.NET 2.0 profile service, that's also
| > quite easy, we just need to define our custom class and the simplest
| > approach is to mark it as [Serializable], e.g:
| > =============== ==========
| > [Serializable]
| > public class MyUnit
| > {
| > public string Name = string.Empty;
| > public int Count =0;
| > public bool Enabled = false;
| > }
| > =============== ===========
| >
| >
| > and then, we just need to declare it in the web.config as below:
| >
| > <system.web>
| > <profile enabled="true" automaticSaveEn abled="true" >
| > <properties >
| > <add name="MyUnit" readOnly="false "
| > type="CustomPro fileClasses.MyU nit" serializeAs="Bi nary"/>
| > ............... ...........
| >
| > #note that we use "serilizeAs='Bi nary'" because we have mark the class
as
| > "Serializab le"
| >
| > Then, we can just access that profile property in page code like:
| >
| > Page_load
| > {
| > Profile.MyUnit. Count = 3;
| > Profile.MyUnit. Name = "fdfda";
| > }
| >
| >
| > If there're any other ideas or questions, please feel free to post here.
| >
| > Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure! www.microsoft.com/security
| > (This posting is provided "AS IS", with no warranties, and confers no
| > rights.)
| >
| >
| >
| >
| >
| >
| >
| >
| > --------------------
| > | From: "Keith Patrick" <ri************ *******@nospam. hotmail.com>
| > | References: <OU************ **@TK2MSFTNGP10 .phx.gbl>
| > | Subject: Re: Profile or Custom Class How to migrate to ASP.NEt 2.0
| > | Date: Thu, 17 Nov 2005 20:14:16 -0600
| > | Lines: 11
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| > | X-RFC2646: Format=Flowed; Response
| > | Message-ID: <OC************ **@TK2MSFTNGP14 .phx.gbl>
| > | Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| > | NNTP-Posting-Host: cpe-24-175-26-193.houston.res .rr.com 24.175.26.193
| > | Path: TK2MSFTNGXA02.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP14.phx. gbl
| > | Xref: TK2MSFTNGXA02.p hx.gbl
| > microsoft.publi c.dotnet.framew ork.aspnet:3591 00
| > | X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
| > |
| > | At first, I figured it would be better to wrap the profile and session
| > under
| > | one user class to maintain app compatibility in scenarios like this.
| > And
| > | for backwards compatibility and abstraction, there are advantages to
| > | abstracting profile and session into a single user class. However,
| > | ultimately, you will still need to use the profile and session to take
| > full
| > | advantage of the GridView-DataSourceContr ol relationship (they are
| > designed
| > | to pull values from Form, Session, Profile, QueryString, and one or
two
| > | other state storage areas), so it's best to store the custom data with
| > the
| > | profile in the underlying impelmentation
| > |
| > |
| > |
| >
|
|
|

Nov 20 '05 #5
That you Steven.
I think this is clear enough.
Shimon.
"Steven Cheng[MSFT]" <st*****@online .microsoft.com> wrote in message
news:Nc******** ******@TK2MSFTN GXA02.phx.gbl.. .
Hi Shimon,

Thanks for your response. Regarding on your further questions:

=============== ===
I have class like this
public class Employee
{
public string LastName{get{.. .}set{...}}
public string FirstName{get{. ..}set{...}}
public string Email{get{...}s et{...}}
public int Id{get{...}set{ ...}}
}

So I will change config file for something like this
<profile enabled="true">
<properties>
<add name = "LastName" type="string"/>
<add name = "FirstName" type="string"/>
<add name = "Email" type="string"/>
<add name = "Id" type="int"/>

</properties>
</profile>
=============== ======

Not exactly, actually, we should mark the custom class with [Serializable]
attribute as below:

[Serializable]
public class Employee
{ ............}
Then, in web.config, we can config it as following:

<profile enabled="true">
<properties>
<add name = "EmployeeIn fo" type="OurNamesp ace.Employee"
serializeAs="Bi nary" />
</properties>
</profile>

Then, we can reference that Profile property in code like:

void Page_Load(....)
{
string firstname = Profile.Employe eInfo.FirstName ;
............
}
If we directly define the "FirstName" , "LastName" ... as Profile
properties like:

<profile enabled="true">
<properties>
<add name = "LastName" type="string"/>
<add name = "FirstName" type="string"/>
............... ....
We can use them as following:

void Page_Load(....)
{
string firstname = Profile.FirstNa me;
string lastname = Profile.LastNam e;
............
}


=============== ==
Then I will need to implement MembershipProvi der, don't I?
=============== ===

Yes, you can implement your custom MembershipProvi der. However, ASP.NET
2.0
has provided SqlServer membership provider which can help store user
account info in sqlserver database (or SQLExpress), does this build-in
provider meet your requirement? Also, the default Provider for Profile
Services is also SQLserver provider(using SQlExpress database...)

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

I don't need to save anything I just want to keep user information
available
for processing.

Then I will need to implement MembershipProvi der, don't I?
--------------------
| From: "Shimon Sim" <sh**********@c ommunity.nospam >
| References: <OU************ **@TK2MSFTNGP10 .phx.gbl>
<OC************ **@TK2MSFTNGP14 .phx.gbl>
<KB************ **@TK2MSFTNGXA0 2.phx.gbl>
| Subject: Re: Profile or Custom Class How to migrate to ASP.NEt 2.0
| Date: Fri, 18 Nov 2005 08:39:22 -0500
| Lines: 154
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| X-RFC2646: Format=Flowed; Original
| Message-ID: <#p************ **@TK2MSFTNGP09 .phx.gbl>
| Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| NNTP-Posting-Host: ool-44c05922.dyn.op tonline.net 68.192.89.34
| Path: TK2MSFTNGXA02.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP09.phx. gbl
| Xref: TK2MSFTNGXA02.p hx.gbl
microsoft.publi c.dotnet.framew ork.aspnet:3592 07
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
|
| So let me see if I understood you right.
| I have class like this
| public class Employee
| {
| public string LastName{get{.. .}set{...}}
| public string FirstName{get{. ..}set{...}}
| public string Email{get{...}s et{...}}
| public int Id{get{...}set{ ...}}
| }
|
| So I will change config file for something like this
| <profile enabled="true">
| <properties>
| <add name = "LastName" type="string"/>
| <add name = "FirstName" type="string"/>
| <add name = "Email" type="string"/>
| <add name = "Id" type="int"/>
|
| </properties>
| </profile>
|
| I don't need to save anything I just want to keep user information
available
| for processing.
|
| Then I will need to implement MembershipProvi der, don't I?
|
| And that's it.
| Correct?
| Shimon.
|
|
| "Steven Cheng[MSFT]" <st*****@online .microsoft.com> wrote in message
| news:KB******** ******@TK2MSFTN GXA02.phx.gbl.. .
| > Thanks for Keith's detailed input.
| >
| > Hi Shimon,
| >
| > Welcome to ASPNET newsgroup.
| > Regarding on the scenario you mentioned, I'm not sure whether your
| > original
| > web application is using Froms Authentication and then associate the
| > Session-Data with each authenticated(l ogin ) user. in ASP.NET 2.0 the
| > profile service can help store some user specific data, and the user
will
| > be the current User of the ASP.NET request, so if you're using
| > FormsAuthentica tion(and the corresponding membership service in
asp.net
| > 2.0), we can make use of the Profile service to store such data. So
each
| > authenticated user will be associated to his own custom datas. Also,
in
| > asp.net 2.0 we can also turn on anonymous:
| >
| > <system.web>
| > <anonymousIdent ification enabled="true" />
| > ..........
| >
| > so that anonymous (unauthenticate d) user can also have such user
specific
| > data (through an anonymous user id), and this is just some what like a
id
| > associcated with a client session( maintained by cookie....). So the
| > first thing here is make sure the "User" concept here matchs the one
in
| > your original asp.net 1.1 application, if so, I think we can migrate
to
| > use
| > ASP.NET 2.0 profile services well. Otherwise, we may need to do some
| > changes ....
| >
| > As for storing custom data in ASP.NET 2.0 profile service, that's also
| > quite easy, we just need to define our custom class and the simplest
| > approach is to mark it as [Serializable], e.g:
| > =============== ==========
| > [Serializable]
| > public class MyUnit
| > {
| > public string Name = string.Empty;
| > public int Count =0;
| > public bool Enabled = false;
| > }
| > =============== ===========
| >
| >
| > and then, we just need to declare it in the web.config as below:
| >
| > <system.web>
| > <profile enabled="true" automaticSaveEn abled="true" >
| > <properties >
| > <add name="MyUnit" readOnly="false "
| > type="CustomPro fileClasses.MyU nit" serializeAs="Bi nary"/>
| > ............... ...........
| >
| > #note that we use "serilizeAs='Bi nary'" because we have mark the class
as
| > "Serializab le"
| >
| > Then, we can just access that profile property in page code like:
| >
| > Page_load
| > {
| > Profile.MyUnit. Count = 3;
| > Profile.MyUnit. Name = "fdfda";
| > }
| >
| >
| > If there're any other ideas or questions, please feel free to post
here.
| >
| > Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure! www.microsoft.com/security
| > (This posting is provided "AS IS", with no warranties, and confers no
| > rights.)
| >
| >
| >
| >
| >
| >
| >
| >
| > --------------------
| > | From: "Keith Patrick" <ri************ *******@nospam. hotmail.com>
| > | References: <OU************ **@TK2MSFTNGP10 .phx.gbl>
| > | Subject: Re: Profile or Custom Class How to migrate to ASP.NEt 2.0
| > | Date: Thu, 17 Nov 2005 20:14:16 -0600
| > | Lines: 11
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| > | X-RFC2646: Format=Flowed; Response
| > | Message-ID: <OC************ **@TK2MSFTNGP14 .phx.gbl>
| > | Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| > | NNTP-Posting-Host: cpe-24-175-26-193.houston.res .rr.com
24.175.26.193
| > | Path:
TK2MSFTNGXA02.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP14.phx. gbl
| > | Xref: TK2MSFTNGXA02.p hx.gbl
| > microsoft.publi c.dotnet.framew ork.aspnet:3591 00
| > | X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
| > |
| > | At first, I figured it would be better to wrap the profile and
session
| > under
| > | one user class to maintain app compatibility in scenarios like this.
| > And
| > | for backwards compatibility and abstraction, there are advantages to
| > | abstracting profile and session into a single user class. However,
| > | ultimately, you will still need to use the profile and session to
take
| > full
| > | advantage of the GridView-DataSourceContr ol relationship (they are
| > designed
| > | to pull values from Form, Session, Profile, QueryString, and one or
two
| > | other state storage areas), so it's best to store the custom data
with
| > the
| > | profile in the underlying impelmentation
| > |
| > |
| > |
| >
|
|
|

Nov 20 '05 #6
You're welcome Shimon,

Good Luck!

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| From: "Shimon Sim" <sh**********@c ommunity.nospam >
| References: <OU************ **@TK2MSFTNGP10 .phx.gbl>
<OC************ **@TK2MSFTNGP14 .phx.gbl>
<KB************ **@TK2MSFTNGXA0 2.phx.gbl>
<#p************ **@TK2MSFTNGP09 .phx.gbl>
<Nc************ **@TK2MSFTNGXA0 2.phx.gbl>
| Subject: Re: Profile or Custom Class How to migrate to ASP.NEt 2.0
| Date: Sun, 20 Nov 2005 13:34:21 -0500
| Lines: 304
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-RFC2646: Format=Flowed; Original
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| Message-ID: <uv************ **@TK2MSFTNGP14 .phx.gbl>
| Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| NNTP-Posting-Host: ool-44c05922.dyn.op tonline.net 68.192.89.34
| Path: TK2MSFTNGXA02.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP14.phx. gbl
| Xref: TK2MSFTNGXA02.p hx.gbl
microsoft.publi c.dotnet.framew ork.aspnet:3596 25
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
|
| That you Steven.
| I think this is clear enough.
| Shimon.
| "Steven Cheng[MSFT]" <st*****@online .microsoft.com> wrote in message
| news:Nc******** ******@TK2MSFTN GXA02.phx.gbl.. .
| > Hi Shimon,
| >
| > Thanks for your response. Regarding on your further questions:
| >
| > =============== ===
| > I have class like this
| > public class Employee
| > {
| > public string LastName{get{.. .}set{...}}
| > public string FirstName{get{. ..}set{...}}
| > public string Email{get{...}s et{...}}
| > public int Id{get{...}set{ ...}}
| > }
| >
| > So I will change config file for something like this
| > <profile enabled="true">
| > <properties>
| > <add name = "LastName" type="string"/>
| > <add name = "FirstName" type="string"/>
| > <add name = "Email" type="string"/>
| > <add name = "Id" type="int"/>
| >
| > </properties>
| > </profile>
| > =============== ======
| >
| > Not exactly, actually, we should mark the custom class with
[Serializable]
| > attribute as below:
| >
| > [Serializable]
| > public class Employee
| > { ............}
| >
| >
| > Then, in web.config, we can config it as following:
| >
| > <profile enabled="true">
| > <properties>
| > <add name = "EmployeeIn fo" type="OurNamesp ace.Employee"
| > serializeAs="Bi nary" />
| > </properties>
| > </profile>
| >
| > Then, we can reference that Profile property in code like:
| >
| > void Page_Load(....)
| > {
| > string firstname = Profile.Employe eInfo.FirstName ;
| > ............
| > }
| >
| >
| > If we directly define the "FirstName" , "LastName" ... as Profile
| > properties like:
| >
| > <profile enabled="true">
| > <properties>
| > <add name = "LastName" type="string"/>
| > <add name = "FirstName" type="string"/>
| > ............... ....
| >
| >
| > We can use them as following:
| >
| > void Page_Load(....)
| > {
| > string firstname = Profile.FirstNa me;
| > string lastname = Profile.LastNam e;
| > ............
| > }
| >
| >
| >
| >
| > =============== ==
| > Then I will need to implement MembershipProvi der, don't I?
| > =============== ===
| >
| > Yes, you can implement your custom MembershipProvi der. However, ASP.NET
| > 2.0
| > has provided SqlServer membership provider which can help store user
| > account info in sqlserver database (or SQLExpress), does this build-in
| > provider meet your requirement? Also, the default Provider for Profile
| > Services is also SQLserver provider(using SQlExpress database...)
| >
| > Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure! www.microsoft.com/security
| > (This posting is provided "AS IS", with no warranties, and confers no
| > rights.)
| >
| >
| >
| >
| >
| > I don't need to save anything I just want to keep user information
| > available
| > for processing.
| >
| > Then I will need to implement MembershipProvi der, don't I?
| > --------------------
| > | From: "Shimon Sim" <sh**********@c ommunity.nospam >
| > | References: <OU************ **@TK2MSFTNGP10 .phx.gbl>
| > <OC************ **@TK2MSFTNGP14 .phx.gbl>
| > <KB************ **@TK2MSFTNGXA0 2.phx.gbl>
| > | Subject: Re: Profile or Custom Class How to migrate to ASP.NEt 2.0
| > | Date: Fri, 18 Nov 2005 08:39:22 -0500
| > | Lines: 154
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| > | X-RFC2646: Format=Flowed; Original
| > | Message-ID: <#p************ **@TK2MSFTNGP09 .phx.gbl>
| > | Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| > | NNTP-Posting-Host: ool-44c05922.dyn.op tonline.net 68.192.89.34
| > | Path: TK2MSFTNGXA02.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP09.phx. gbl
| > | Xref: TK2MSFTNGXA02.p hx.gbl
| > microsoft.publi c.dotnet.framew ork.aspnet:3592 07
| > | X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
| > |
| > | So let me see if I understood you right.
| > | I have class like this
| > | public class Employee
| > | {
| > | public string LastName{get{.. .}set{...}}
| > | public string FirstName{get{. ..}set{...}}
| > | public string Email{get{...}s et{...}}
| > | public int Id{get{...}set{ ...}}
| > | }
| > |
| > | So I will change config file for something like this
| > | <profile enabled="true">
| > | <properties>
| > | <add name = "LastName" type="string"/>
| > | <add name = "FirstName" type="string"/>
| > | <add name = "Email" type="string"/>
| > | <add name = "Id" type="int"/>
| > |
| > | </properties>
| > | </profile>
| > |
| > | I don't need to save anything I just want to keep user information
| > available
| > | for processing.
| > |
| > | Then I will need to implement MembershipProvi der, don't I?
| > |
| > | And that's it.
| > | Correct?
| > | Shimon.
| > |
| > |
| > | "Steven Cheng[MSFT]" <st*****@online .microsoft.com> wrote in message
| > | news:KB******** ******@TK2MSFTN GXA02.phx.gbl.. .
| > | > Thanks for Keith's detailed input.
| > | >
| > | > Hi Shimon,
| > | >
| > | > Welcome to ASPNET newsgroup.
| > | > Regarding on the scenario you mentioned, I'm not sure whether your
| > | > original
| > | > web application is using Froms Authentication and then associate the
| > | > Session-Data with each authenticated(l ogin ) user. in ASP.NET 2.0
the
| > | > profile service can help store some user specific data, and the user
| > will
| > | > be the current User of the ASP.NET request, so if you're using
| > | > FormsAuthentica tion(and the corresponding membership service in
| > asp.net
| > | > 2.0), we can make use of the Profile service to store such data. So
| > each
| > | > authenticated user will be associated to his own custom datas.
Also,
| > in
| > | > asp.net 2.0 we can also turn on anonymous:
| > | >
| > | > <system.web>
| > | > <anonymousIdent ification enabled="true" />
| > | > ..........
| > | >
| > | > so that anonymous (unauthenticate d) user can also have such user
| > specific
| > | > data (through an anonymous user id), and this is just some what
like a
| > id
| > | > associcated with a client session( maintained by cookie....). So
the
| > | > first thing here is make sure the "User" concept here matchs the
one
| > in
| > | > your original asp.net 1.1 application, if so, I think we can
migrate
| > to
| > | > use
| > | > ASP.NET 2.0 profile services well. Otherwise, we may need to do some
| > | > changes ....
| > | >
| > | > As for storing custom data in ASP.NET 2.0 profile service, that's
also
| > | > quite easy, we just need to define our custom class and the simplest
| > | > approach is to mark it as [Serializable], e.g:
| > | > =============== ==========
| > | > [Serializable]
| > | > public class MyUnit
| > | > {
| > | > public string Name = string.Empty;
| > | > public int Count =0;
| > | > public bool Enabled = false;
| > | > }
| > | > =============== ===========
| > | >
| > | >
| > | > and then, we just need to declare it in the web.config as below:
| > | >
| > | > <system.web>
| > | > <profile enabled="true" automaticSaveEn abled="true" >
| > | > <properties >
| > | > <add name="MyUnit" readOnly="false "
| > | > type="CustomPro fileClasses.MyU nit" serializeAs="Bi nary"/>
| > | > ............... ...........
| > | >
| > | > #note that we use "serilizeAs='Bi nary'" because we have mark the
class
| > as
| > | > "Serializab le"
| > | >
| > | > Then, we can just access that profile property in page code like:
| > | >
| > | > Page_load
| > | > {
| > | > Profile.MyUnit. Count = 3;
| > | > Profile.MyUnit. Name = "fdfda";
| > | > }
| > | >
| > | >
| > | > If there're any other ideas or questions, please feel free to post
| > here.
| > | >
| > | > Thanks,
| > | >
| > | > Steven Cheng
| > | > Microsoft Online Support
| > | >
| > | > Get Secure! www.microsoft.com/security
| > | > (This posting is provided "AS IS", with no warranties, and confers
no
| > | > rights.)
| > | >
| > | >
| > | >
| > | >
| > | >
| > | >
| > | >
| > | >
| > | > --------------------
| > | > | From: "Keith Patrick" <ri************ *******@nospam. hotmail.com>
| > | > | References: <OU************ **@TK2MSFTNGP10 .phx.gbl>
| > | > | Subject: Re: Profile or Custom Class How to migrate to ASP.NEt 2.0
| > | > | Date: Thu, 17 Nov 2005 20:14:16 -0600
| > | > | Lines: 11
| > | > | X-Priority: 3
| > | > | X-MSMail-Priority: Normal
| > | > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| > | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| > | > | X-RFC2646: Format=Flowed; Response
| > | > | Message-ID: <OC************ **@TK2MSFTNGP14 .phx.gbl>
| > | > | Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| > | > | NNTP-Posting-Host: cpe-24-175-26-193.houston.res .rr.com
| > 24.175.26.193
| > | > | Path:
| > TK2MSFTNGXA02.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP14.phx. gbl
| > | > | Xref: TK2MSFTNGXA02.p hx.gbl
| > | > microsoft.publi c.dotnet.framew ork.aspnet:3591 00
| > | > | X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
| > | > |
| > | > | At first, I figured it would be better to wrap the profile and
| > session
| > | > under
| > | > | one user class to maintain app compatibility in scenarios like
this.
| > | > And
| > | > | for backwards compatibility and abstraction, there are advantages
to
| > | > | abstracting profile and session into a single user class.
However,
| > | > | ultimately, you will still need to use the profile and session to
| > take
| > | > full
| > | > | advantage of the GridView-DataSourceContr ol relationship (they are
| > | > designed
| > | > | to pull values from Form, Session, Profile, QueryString, and one
or
| > two
| > | > | other state storage areas), so it's best to store the custom data
| > with
| > | > the
| > | > | profile in the underlying impelmentation
| > | > |
| > | > |
| > | > |
| > | >
| > |
| > |
| > |
| >
|
|
|

Nov 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1969
by: | last post by:
Hi all, How can I get a reference to my custom profile provider in my .aspx page? I have looked at httpcontext.current.profile. But from there where do I go? Ideally I would like to be able to get default profile provider without having to know the "name" configured in web.config. TIA!
0
2554
by: Giorgio | last post by:
It seems that the ASP.NET Microsoft team didn't think about this!! The profilemanager class has the following methods: - DeleteInactiveProfiles. Enables you to delete all profiles older than a specified date. - DeleteProfile. Enables you to delete a profile associated with a
0
1945
by: a | last post by:
Q. Unable to get a Profile custom (object) collection to bind to GridView,etc (IList objects)? This is my first custom object so I may be doing something rather simple, wrong, or it may be something else to do with the Profile object. Either way, I need help Here's a brief description of the...
0
1827
by: a | last post by:
I need to create an instance of a custom object 'School.Teacher' and use it in a Profile object. I'm developing a bad case of "Pretzel Logic" thinking about this. Filling the custom object 'School.Teacher' as an ArrayList creates the proper information (see aspx code below), but I'm unable to use this ArrayList in the Profile object....
0
1133
by: ashish | last post by:
hi all, I am working with a custom profile provider that stores my business object as profile with anonymous identification turned on. I have a question regarding how it is supposed to work with forms authentication etc We want to remember user settings every time they visit the site, anonymous or not
9
3095
by: Eric Falsken | last post by:
I've added a number of additional properties to my profile. Sometimes, the values are populated when the user is retrieved from the database, but sometimes the values are empty/default. How can I make sure that the values are always populated correctly? Further example, my website is working reliably enough, but I'm trying to access the...
1
1347
by: shapper | last post by:
Hello, I have a profile with multiple profile properties in my Web.Config: <add allowAnonymous="false" name="Contact" type="Contact" serializeAs="Binary"/> <add allowAnonymous="false" name="Options" type="Options" serializeAs="Binary"/> Where each profile property is class, as follows:
9
3266
by: Kirk | last post by:
I have successfully, implemented a custom Membership Provider to a SQL 2000 table, however, I am having problems doing the same with a Profile Provider. As I understand it, the steps for both of these are similar: Create a new class (MyMembershipProvider and MyProfileProvider). Add the "Inherits..." value to the provider...
5
1660
by: Steven | last post by:
I have the following in my web.config: <system.web> <profile defaultProvider="MyASPSqlProfileProvider" enabled="true" > <properties> <add name="FirstName" defaultValue="" type="string"/> <add name="MiddleInitial" defaultValue="" type="string" /> <add name="LastName" defaultValue="" type="string"/> <add name="Address1" defaultValue=""...
0
7726
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8052
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8098
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6452
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5620
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3740
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3749
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2243
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1060
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.