Custom User properties/methods in ASP.Net Membership
I'd like to add some custom instance properties to an ASP.Net User object. for example, I'd like to log every user's login and have something like: User.LoginTimes
or calculate the User Profile's Completion percentage and be able to access it like: User.ProfileInfoPercentage
, etc.
Now What I'd like to know is what would be the best approach to do this?
Forget about user instances? (e.g. define a database table with userid and ProfilePercentage info and retrieve data from profile like:
DB.GetProfilePercentage(Context.Current.User.UserID)
)Override the ASP.Net User class and add my own functionalities.
Use 开发者_如何学JAVAExtension methods for the user class.
Any other way that I'm not aware of?
The easiest way may be to use Asp .Net Profile if you will need only small amounts of data. You could use the SqlProfileProvider class that is provided by .NET Framework or you can create custom providers that fits your need by implementing System.Web.Profile.ProfileProvider.
精彩评论