ASP.NET MVC 应用程序中的成员资格建议

发布于 2024-09-19 10:14:12 字数 280 浏览 5 评论 0原文

带着这个问题,我主要是从那些在自己的数据库中实现了开箱即用的 ASP.NET 成员身份的人那里寻找答案 - 我已经在数据库中设置了表,据我所知,它们包含大部分是我需要的,但不是全部。我将拥有用户所属的公司(公司)的概念,因此我必须将 aspnet_Users 与我的公司表关联起来(每个用户都将是一个公司的成员)。

如果可能的话,请提供一些指导方针,您是如何做到的,以及如果我将来必须修改表设计,我可能会遇到什么情况。我最好使用默认的会员资格提供商。

我很难决定是从头开始还是使用 ASP.NET 已经提供的功能。

With this question I am mostly looking for answers from people that have implemented the out-of-the-box ASP.NET membership in their own database - I've set up the tables inside my database and as far as I can see they contain mostly what I need but not everything. I will have the notion of a Firm (Company) to which Users will belong so I will have to associate the aspnet_Users with my Firms table (each user will be a member of exactly one firm).

If possible, provide some guidelines how did you do it and what I might run into if I have to modify the table design at some point in the future. Preferably I will be using the default Membership provider.

I am having trouble to decide whether to go from scratch or use what ASP.NET already offers.

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

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

发布评论

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

评论(3

离不开的别离 2024-09-26 10:14:12

我建议您需要使用基于表的配置文件提供程序实现,例如这个是 Scott Guthrie 在博客中提到的。它比开箱即用的配置文件提供程序要好得多,因为它允许您定义自己的配置文件信息表。在您的情况下,您将有一个表,其中包含每个用户的行和 FirmId 以及您喜欢的任何其他内容,例如昵称、社会安全号码等。

它与默认的会员资格提供商一起使用,因此您无需对其进行任何更改。该示例中有两种实现,一种是基于存储过程的,一种是基于表的。我更喜欢第二种,但它们都非常易于使用。

事实证明,默认的配置文件提供程序有点垃圾,因为它将所有用户信息存储在单个字段中。我建议的提供商以非常有效的方式解决了这个问题。

I would suggest that you need to use a table-based Profile Provider implementation such as this one that Scott Guthrie blogged about. It is much better than the out-of-the-box profile provider as it allows you to define your own tables for profile information. In your case you would have a table that contains a Row per user and a FirmId and anything else you like such as nick name, social security number, whatever.

It works with the default Membership provider so you won't have to make any changes to it. There are two implementations in the example, a Stored Procedure based one and a Table based one. I prefer the second but they are both very easy to use.

The default profile provider proved a bit rubbish because it stored all of a user's information in a single field. The provider that I suggested solves this in a very efficient way.

吻风 2024-09-26 10:14:12

由于未来版本中可能会引入更改,我决定不使用 ASP.NET 成员资格提供程序及其默认表,因此我最终最终使用 这个由 OmidID 提供的自定义实体框架 提供程序,尽管我必须对它进行很多调整。但我现在可以说,我们有一个相当完善的基于实体框架的成员资格提供程序,我们可以轻松维护它,并且独立于 SQL Server 中的 ASP.NET 成员资格表。

I decided not to use ASP.NET Membership provider and its default tables because of the changes that might be introduced in future versions, so I eventually ended up using this custom Entity Framework provider by OmidID although I had to tweak it quite a lot. But I can now say that we have a rather fullproof entity framework based membership provider that we can easily maintain and indenpendent of the ASP.NET membership tables in SQL Server.

ㄟ。诗瑗 2024-09-26 10:14:12

我将 ASP.NET 会员资格视为一项单独的服务。只需按原样使用它并在其上添加任何附加功能即可。

在本例中,只需创建一个将用户链接到公司的表,但不更改 ASP.NET 表。如果您需要存储有关用户的任何其他信息,请将其放入与 ASP.NET 成员资格用户表关联的另一个表中。

更新:我已开始使用此 ASP.NET MVC 区域来管理用户和角色 https ://github.com/TroyGoode/MembershipStarterKit。它配备了所有必要的模型、视图和控制器,并且经过了全面的单元测试。不到一个多小时就将其集成到我的网站中并启动并运行。

I would treat the ASP.NET membership as a separate service. Just use it as is and add any additional functionality on top of it.

In this case just create a table which links the users to the companies but don't alter the ASP.NET tables. If you have any additional information you need to store about users put this in another table which is associated with the ASP.NET membership users table.

Update: I've started using this ASP.NET MVC Area to administer users and roles https://github.com/TroyGoode/MembershipStarterKit. It comes with all the necessary models, views and controllers and is fully unit tested. Didn't take more than an hour to get it integrated into my site and up and running.

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