Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Profile or Custom Class How to migrate to ASP.NEt 2.0

Reply
Thread Tools

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

 
 
Shimon Sim
Guest
Posts: n/a
 
      11-17-2005
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


 
Reply With Quote
 
 
 
 
Keith Patrick
Guest
Posts: n/a
 
      11-18-2005
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-DataSourceControl 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


 
Reply With Quote
 
 
 
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      11-18-2005
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(login ) 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
FormsAuthentication(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>
<anonymousIdentification enabled="true" />
...........

so that anonymous (unauthenticated) 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" automaticSaveEnabled="true" >
<properties >
<add name="MyUnit" readOnly="false"
type="CustomProfileClasses.MyUnit" serializeAs="Binary"/>
...........................

#note that we use "serilizeAs='Binary'" because we have mark the class as
"Serializable"

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" <(E-Mail Removed)>
| References: <(E-Mail Removed)>
| 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: <OClKGX#(E-Mail Removed)>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: cpe-24-175-26-193.houston.res.rr.com 24.175.26.193
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP14.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:359100
| X-Tomcat-NG: microsoft.public.dotnet.framework.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-DataSourceControl 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
|
|
|

 
Reply With Quote
 
Shimon Sim
Guest
Posts: n/a
 
      11-18-2005
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{...}set{...}}
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 MembershipProvider, don't I?

And that's it.
Correct?
Shimon.


"Steven Cheng[MSFT]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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(login ) 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
> FormsAuthentication(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>
> <anonymousIdentification enabled="true" />
> ..........
>
> so that anonymous (unauthenticated) 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" automaticSaveEnabled="true" >
> <properties >
> <add name="MyUnit" readOnly="false"
> type="CustomProfileClasses.MyUnit" serializeAs="Binary"/>
> ..........................
>
> #note that we use "serilizeAs='Binary'" because we have mark the class as
> "Serializable"
>
> 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" <(E-Mail Removed)>
> | References: <(E-Mail Removed)>
> | 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: <OClKGX#(E-Mail Removed)>
> | Newsgroups: microsoft.public.dotnet.framework.aspnet
> | NNTP-Posting-Host: cpe-24-175-26-193.houston.res.rr.com 24.175.26.193
> | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP14.phx.gbl
> | Xref: TK2MSFTNGXA02.phx.gbl
> microsoft.public.dotnet.framework.aspnet:359100
> | X-Tomcat-NG: microsoft.public.dotnet.framework.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-DataSourceControl 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
> |
> |
> |
>



 
Reply With Quote
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      11-20-2005
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{...}set{...}}
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 = "EmployeeInfo" type="OurNamespace.Employee"
serializeAs="Binary" />
</properties>
</profile>

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

void Page_Load(....)
{
string firstname = Profile.EmployeeInfo.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.FirstName;
string lastname = Profile.LastName;
............
}




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

Yes, you can implement your custom MembershipProvider. 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 MembershipProvider, don't I?
--------------------
| From: "Shimon Sim" <(E-Mail Removed)>
| References: <(E-Mail Removed)>
<OClKGX#(E-Mail Removed)>
<(E-Mail Removed)>
| 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: <#(E-Mail Removed)>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: ool-44c05922.dyn.optonline.net 68.192.89.34
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP09.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:359207
| X-Tomcat-NG: microsoft.public.dotnet.framework.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{...}set{...}}
| 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 MembershipProvider, don't I?
|
| And that's it.
| Correct?
| Shimon.
|
|
| "Steven Cheng[MSFT]" <(E-Mail Removed)> wrote in message
| news:(E-Mail Removed)...
| > 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(login ) 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
| > FormsAuthentication(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>
| > <anonymousIdentification enabled="true" />
| > ..........
| >
| > so that anonymous (unauthenticated) 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" automaticSaveEnabled="true" >
| > <properties >
| > <add name="MyUnit" readOnly="false"
| > type="CustomProfileClasses.MyUnit" serializeAs="Binary"/>
| > ..........................
| >
| > #note that we use "serilizeAs='Binary'" because we have mark the class
as
| > "Serializable"
| >
| > 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" <(E-Mail Removed)>
| > | References: <(E-Mail Removed)>
| > | 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: <OClKGX#(E-Mail Removed)>
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet
| > | NNTP-Posting-Host: cpe-24-175-26-193.houston.res.rr.com 24.175.26.193
| > | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP14.phx.gbl
| > | Xref: TK2MSFTNGXA02.phx.gbl
| > microsoft.public.dotnet.framework.aspnet:359100
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.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-DataSourceControl 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
| > |
| > |
| > |
| >
|
|
|

 
Reply With Quote
 
Shimon Sim
Guest
Posts: n/a
 
      11-20-2005
That you Steven.
I think this is clear enough.
Shimon.
"Steven Cheng[MSFT]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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{...}set{...}}
> 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 = "EmployeeInfo" type="OurNamespace.Employee"
> serializeAs="Binary" />
> </properties>
> </profile>
>
> Then, we can reference that Profile property in code like:
>
> void Page_Load(....)
> {
> string firstname = Profile.EmployeeInfo.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.FirstName;
> string lastname = Profile.LastName;
> ............
> }
>
>
>
>
> =================
> Then I will need to implement MembershipProvider, don't I?
> ==================
>
> Yes, you can implement your custom MembershipProvider. 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 MembershipProvider, don't I?
> --------------------
> | From: "Shimon Sim" <(E-Mail Removed)>
> | References: <(E-Mail Removed)>
> <OClKGX#(E-Mail Removed)>
> <(E-Mail Removed)>
> | 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: <#(E-Mail Removed)>
> | Newsgroups: microsoft.public.dotnet.framework.aspnet
> | NNTP-Posting-Host: ool-44c05922.dyn.optonline.net 68.192.89.34
> | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP09.phx.gbl
> | Xref: TK2MSFTNGXA02.phx.gbl
> microsoft.public.dotnet.framework.aspnet:359207
> | X-Tomcat-NG: microsoft.public.dotnet.framework.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{...}set{...}}
> | 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 MembershipProvider, don't I?
> |
> | And that's it.
> | Correct?
> | Shimon.
> |
> |
> | "Steven Cheng[MSFT]" <(E-Mail Removed)> wrote in message
> | news:(E-Mail Removed)...
> | > 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(login ) 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
> | > FormsAuthentication(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>
> | > <anonymousIdentification enabled="true" />
> | > ..........
> | >
> | > so that anonymous (unauthenticated) 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" automaticSaveEnabled="true" >
> | > <properties >
> | > <add name="MyUnit" readOnly="false"
> | > type="CustomProfileClasses.MyUnit" serializeAs="Binary"/>
> | > ..........................
> | >
> | > #note that we use "serilizeAs='Binary'" because we have mark the class
> as
> | > "Serializable"
> | >
> | > 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" <(E-Mail Removed)>
> | > | References: <(E-Mail Removed)>
> | > | 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: <OClKGX#(E-Mail Removed)>
> | > | Newsgroups: microsoft.public.dotnet.framework.aspnet
> | > | NNTP-Posting-Host: cpe-24-175-26-193.houston.res.rr.com
> 24.175.26.193
> | > | Path:
> TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP14.phx.gbl
> | > | Xref: TK2MSFTNGXA02.phx.gbl
> | > microsoft.public.dotnet.framework.aspnet:359100
> | > | X-Tomcat-NG: microsoft.public.dotnet.framework.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-DataSourceControl 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
> | > |
> | > |
> | > |
> | >
> |
> |
> |
>



 
Reply With Quote
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      11-21-2005
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" <(E-Mail Removed)>
| References: <(E-Mail Removed)>
<OClKGX#(E-Mail Removed)>
<(E-Mail Removed)>
<#(E-Mail Removed)>
<(E-Mail Removed)>
| 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: <(E-Mail Removed)>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: ool-44c05922.dyn.optonline.net 68.192.89.34
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP14.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:359625
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| That you Steven.
| I think this is clear enough.
| Shimon.
| "Steven Cheng[MSFT]" <(E-Mail Removed)> wrote in message
| news:(E-Mail Removed)...
| > 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{...}set{...}}
| > 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 = "EmployeeInfo" type="OurNamespace.Employee"
| > serializeAs="Binary" />
| > </properties>
| > </profile>
| >
| > Then, we can reference that Profile property in code like:
| >
| > void Page_Load(....)
| > {
| > string firstname = Profile.EmployeeInfo.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.FirstName;
| > string lastname = Profile.LastName;
| > ............
| > }
| >
| >
| >
| >
| > =================
| > Then I will need to implement MembershipProvider, don't I?
| > ==================
| >
| > Yes, you can implement your custom MembershipProvider. 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 MembershipProvider, don't I?
| > --------------------
| > | From: "Shimon Sim" <(E-Mail Removed)>
| > | References: <(E-Mail Removed)>
| > <OClKGX#(E-Mail Removed)>
| > <(E-Mail Removed)>
| > | 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: <#(E-Mail Removed)>
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet
| > | NNTP-Posting-Host: ool-44c05922.dyn.optonline.net 68.192.89.34
| > | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP09.phx.gbl
| > | Xref: TK2MSFTNGXA02.phx.gbl
| > microsoft.public.dotnet.framework.aspnet:359207
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.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{...}set{...}}
| > | 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 MembershipProvider, don't I?
| > |
| > | And that's it.
| > | Correct?
| > | Shimon.
| > |
| > |
| > | "Steven Cheng[MSFT]" <(E-Mail Removed)> wrote in message
| > | news:(E-Mail Removed)...
| > | > 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(login ) 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
| > | > FormsAuthentication(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>
| > | > <anonymousIdentification enabled="true" />
| > | > ..........
| > | >
| > | > so that anonymous (unauthenticated) 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" automaticSaveEnabled="true" >
| > | > <properties >
| > | > <add name="MyUnit" readOnly="false"
| > | > type="CustomProfileClasses.MyUnit" serializeAs="Binary"/>
| > | > ..........................
| > | >
| > | > #note that we use "serilizeAs='Binary'" because we have mark the
class
| > as
| > | > "Serializable"
| > | >
| > | > 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" <(E-Mail Removed)>
| > | > | References: <(E-Mail Removed)>
| > | > | 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: <OClKGX#(E-Mail Removed)>
| > | > | Newsgroups: microsoft.public.dotnet.framework.aspnet
| > | > | NNTP-Posting-Host: cpe-24-175-26-193.houston.res.rr.com
| > 24.175.26.193
| > | > | Path:
| > TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP14.phx.gbl
| > | > | Xref: TK2MSFTNGXA02.phx.gbl
| > | > microsoft.public.dotnet.framework.aspnet:359100
| > | > | X-Tomcat-NG: microsoft.public.dotnet.framework.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-DataSourceControl 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
| > | > |
| > | > |
| > | > |
| > | >
| > |
| > |
| > |
| >
|
|
|

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
<profile><properties> with no Profile class Steven ASP .Net 5 10-24-2008 07:23 PM
Visual Studio 2008 asp.net web administration>profile: "The profile wasn't created"? Andy B ASP .Net 0 05-03-2008 05:15 PM
Trying to migrate an anonymous profile to an authenticated one GeoffreyD ASP .Net 2 01-29-2008 10:39 AM
Want to profile monitor for Fuji Frontier ICC profile? Lynn Digital Photography 9 09-08-2005 12:17 PM
Java Web Start app icons keep going in user profile not All Users profile Brad Java 1 07-19-2005 02:10 AM



Advertisments