简体   繁体   中英

Membership Provider

I am currently developing an web site using asp and have a few questions regarding Membership Provider.

I am currently inheriting from Membership Provider class and have just got over the issue of only certain parameters being able to be passed to the CreateUser method.

I have been able to overcome this issue by creating a class that inherits from MembershipUser adding custom properties and then passing that the the UpdateUser method. However to me this seems quite messy and not very efficient as I am making two calls to the database when I could do it in one if I dont use the CreateUserWizard.

So my question is, is using the Provided Login components worthwhile if you are overriding the methods and require more parameters ect in order to keep the use of the properties you can define for this class in the web.config file or is it easier in the long run to just start from scratch. Basically what I want to know is how people have found using Membership by overriding and inheritance over starting from scratch, and how these compare.

Any webpages that talk about this would be good and apologies if the question doesn't make sense or I have missed anything out.

Thanks,

Ric

如果我正确理解了您的问题,那么是的,成员资格提供程序是一个很好的构建基础,因此您不必为身份验证/授权的基础重新发明轮子。

You are using Membership wrong. You should only create your own custom provider when you need to map onto an existing database. IF you are making your own database, then you should just use the default implementation.

Even if you create a custom implementation, you should not do anything that the current membership doesn't already provide. Just map those functions on to your database.

To add additional information, you create a secondary table called UserData or something. This table will be keyed by the MembershipUser.ProviderUserKey, so you lookup any data you need from the other table using the userid from the membership class.

You're really fighting upstream trying to change membership to give you custom things. You can do it, but why cause yourself trouble?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM