在使用MySQL和MVC 3会员加入更多的字段登记表 [英] adding more fields to registration form using membership on MySql and MVC 3
问题描述
我开始一个网站基于asp.net MVC 3和MySQL
我得到了会员与MySQL .NET连接器工作
所以用你的MVC 3的新项目得到默认的应用程序,我有一个工作登记表和工作登录表单
i started a site based on asp.net MVC 3 and MySql i got the membership to work with the MySQL .NET connector so with the default application you get with a new project of mvc 3 i have a working register form and a working login form
但是...我如何添加更多的字段登记表格?
我知道如何将它们添加我的模型,并在页面..但如何让我的会员保持这个新的数据我会为用户?
将我必须通过自己在数据库中的列?或会员资格是否知道如何全自动不知何故创建它们?
but... how do i add more fields to the registration form? i know how to add them my model and to the page.. but how do i make the membership keep this new data ill get for the user? will i have to make the columns in the database by myself? or does membership knows how to create them automaticly somehow?
我只希望3多为登记栏...
i only want 3 more fields for the registration...
感谢
推荐答案
我建议你这个解决方案。
I suggest you this solution.
- 创建一个名为的UserDetails表。
- 添加指向用户ID字段。
您大功告成。
现在,你需要一些类基于用户ID检索放入系统领域。你也可以实现自己的MembershipProvider,并添加像GetUserDetail(),它返回一个包含你的额外域对象的方法。
Now you need some class to retrieve thoses fields based on the userid. You could also implement your own MembershipProvider and add a method like GetUserDetail() which return an object containing your extra fields.
这是基于ASP.NET官方文章:<一href=\"http://www.asp.net/web-forms/tutorials/security/membership/storing-additional-user-information-cs\">http://www.asp.net/web-forms/tutorials/security/membership/storing-additional-user-information-cs
This is based on an official ASP.NET article : http://www.asp.net/web-forms/tutorials/security/membership/storing-additional-user-information-cs
这篇关于在使用MySQL和MVC 3会员加入更多的字段登记表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!