开发者

ASP.NET 2.0 Custom Profile Class Question

开发者 https://www.devze.com 2022-12-16 12:41 出处:网络
I am attempting to design a custom profile class that allows me to access the aspnet tables in addition to my custom tables (all in the same开发者_高级运维 DB).

I am attempting to design a custom profile class that allows me to access the aspnet tables in addition to my custom tables (all in the same开发者_高级运维 DB).

I have been following two online examples that describe how to wire up a custom profile class. In this example, I am asked to inherit from ProfileProvider

How To Implement A Custom Profile Provider

And, in this one, I am asked to inherit from ProfileBase:

Writing a custom ASP.NET Profile Class

What is the difference between these two examples and which way is better? Should I be inheriting from ProfileProvider or ProfileBase? What is the difference?

public class UserProfile : ProfileProvider

public class UserProfile : ProfileBase

Thanks.


The ProfileProvider base class is the provider that creates the object that derives from ProfileBase.

When you specify a custom provider (that is, a type that derives from ProfileProvider), you're writing a class that creates profile objects for a given user. For example, maybe you read the profile data (favorite color, age, location, etc.) from a database, a file on disk, or from a remote web service.

This is useful is you need functionality that is not available in ASP.NET's built in profile provider.

When you specify a custom profile base class (that is, a type that derives from ProfileBase) you're writing a class that represents the profile data itself.

This is useful when you want to have additional functionality on the profile object itself, such as providing additional metadata on the profile properties.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号