ASP Membership tables -> add new property to user?

江枫思渺然 提交于 2019-12-24 19:29:17

问题


I would like to start using ASP.NET's membership classes and tables with a new MVC4 project I am building.

Let's say for example I want to keep track of user's birthdays. When creating the account, how do I add in the birthday? Is this something I keep track of with Profiles? I'm a bit confused on the correct way to add new 'columns' of data for users?


回答1:


To specifically answer your question, here's how Microsoft advises to create extra tables for storing additional user information: Storing Additional User Information

Here is another posting (I would take this approach), its implementing your own profile provider, rather than using default one, so you have full control over what is happening, how it stored etc.: Implementing Profile Provider in ASP.NET MVC Another great article by Microsoft about the same is Manage Web Users With Custom Profile Providers

It totally depends on utility and use. You can either

  1. use default profile provider (exercising)
  2. use custom profile provider (small scale sites)
  3. use your own tables to store user information (enterprise level).

In the latter case you can link between default membership (assuming you using default membership provider) and your custom profile information by including user.Guid inside your table, which is used by default membership as unique identifier.

Hope this information will help you.




回答2:


Profiles is the right way although it has its disadvatages. The data in the database is not in a readable way but in special strings, and profile is loaded on every postback.

Look here: http://msdn.microsoft.com/en-us/library/z1hkazw7(v=vs.100).aspx



来源:https://stackoverflow.com/questions/12099482/asp-membership-tables-add-new-property-to-user

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!