SimpleMemberShipProvider, Using multiple PropertyValues with custom Database tables

﹥>﹥吖頭↗ 提交于 2019-12-14 02:18:40

问题


I am creating a Log in scheme using SimpleMembershipProvider in MVC4. I wanted a little more control than what i get with the out of the box AccountControl. So I have modified the connections to use my database and table, however I would like fields like first name, last name and email to be required.

WebSecurity.CreateUserAndRole(username, password);

fails because of the required field types. I have found that I can use PropertyValues to fix this issue, however I cannot figure out how to make PropertyValues equal more than one value.

WebSecurity.CreateUserAndAccount(user.Username, user.password, propertyValues: new {firstName = user.firstName});

How do I go about using multiple PropertyValues?


回答1:


I'm not sure, but can you maybe try adding another entry to the new {} object you're creating. Something like:

WebSecurity.CreateUserAndAccount(user.Username, user.password,
                                 propertyValues: new {firstName = user.firstName,
                                                      lastName = user.lastName});



回答2:


You must add column (firstName & lastName) to table dbo.UserProfile in aspnet DB (in folder app_data) for using:

WebSecurity.CreateUserAndAccount(model.UserName, model.Password, new {firstName = user.firstName, lastName = user.lastName});


来源:https://stackoverflow.com/questions/14416728/simplemembershipprovider-using-multiple-propertyvalues-with-custom-database-tab

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