asp.Net MVC 将属性添加到 User 类
在我的应用程序中,我想向用户类添加属性。 我该怎么做呢?
我当前的解决方案是在数据库中创建 Users 表,但我刚刚读到 Asp.Net 提供了开箱即用的用户注册 API 和功能。 如何更新新属性?
谢谢
In my app I want to add properties to the user class.
How should I do it?
My current solution is to create Users table in th database, but I just read that Asp.Net provides out-of-the-box users registration API and functionality.
How can I update the new properties?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你的意思是你想要一个定制的校长吗?在这种情况下,您希望挂钩 AuthenticateRequest 方法并添加您自己的派生主体。我最近回答了有关创建自定义主体的问题
Do you mean you want a custom Principal? In that case you want to hook into the AuthenticateRequest method and add your own, derived principal. I recently answered a question regarding the creation of a custom principal here. While that question deals with WindowsAuthentication, the idea is the same:
您可以编写一个插入会员资格和会员资格的自定义会员资格提供程序。框架内置的授权功能。您还可以编写自己的继承自标准类的自定义 User 类。如果需要,您可以对其进行设计,以便它使用现有的用户表。
这对我们的几个不同项目来说效果很好。
这是一些文档:
http://msdn.microsoft.com/en-us/library/f1kyba5e.aspx
You can write a custom Membership Provider that plugs into the membership & authorization features built into the framework. You can also write your own custom User class that inherits from the standard class. You can design it so that it uses your existing users table if you want.
This has worked out well for us on a couple different projects.
Here's some documentation:
http://msdn.microsoft.com/en-us/library/f1kyba5e.aspx