会员提供者

发布于 2024-12-03 13:05:07 字数 484 浏览 1 评论 0原文

我目前正在使用 ASP 开发一个网站,并且有一些关于会员提供商的问题。

我目前继承自 Membership Provider 类,并且刚刚解决了只能将某些参数传递给 CreateUser 方法的问题。

我已经能够通过创建一个继承自 MembershipUser 的类添加自定义属性,然后将其传递给 UpdateUser 方法来克服这个问题。然而对我来说,这似乎很混乱而且效率不高,因为如果我不使用 CreateUserWizard,我可以一次调用数据库,但我却对数据库进行了两次调用。

所以我的问题是,如果您要覆盖这些方法并需要更多参数等,以便继续使用您可以在 web.config 文件中为此类定义的属性,那么使用提供的登录组件是否值得,或者在长远来看只能从头开始。基本上我想知道的是人们如何通过重写和继承来使用会员资格而不是从头开始,以及它们如何进行比较。

任何讨论此问题的网页都会很好,如果问题没有意义或者我错过了任何内容,我们深表歉意。

谢谢,

里克

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一向肩并 2024-12-10 13:05:07

如果我正确理解你的问题,那么是的,会员资格提供者是一个很好的 API,因此你不必重新发明轮子来获取身份验证/授权的基础知识。

If I am understanding your question correctly, then yes the membership provider is a great api to build off of so you don't have to reinvent the wheel for the basics of authentication/authorization.

阳光下的泡沫是彩色的 2024-12-10 13:05:07

您使用会员资格的方式有误。仅当需要映射到现有数据库时,您才应该创建自己的自定义提供程序。如果您正在创建自己的数据库,那么您应该只使用默认实现。

即使您创建了自定义实现,您也不应该执行当前成员身份尚未提供的任何操作。只需将这些函数映射到您的数据库即可。

要添加附加信息,您可以创建一个名为 UserData 或其他名称的辅助表。该表将由 MembershipUser.ProviderUserKey 作为键,因此您可以使用会员资格类别中的用户 ID 从其他表中查找所需的任何数据。

你确实在努力改变会员资格以给你定制的东西。你可以做到,但为什么要给自己找麻烦呢?

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文