开发者

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?

  1. 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) )

  2. Override the ASP.Net User class and add my own functionalities.

  3. Use 开发者_如何学JAVAExtension methods for the user class.

  4. 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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜