简体   繁体   English

如何在ASP.Net成员资格中设置ProviderUserKey

[英]How To Set the ProviderUserKey in ASP.Net Membership

I have a members table in my application. 我的应用程序中有一个成员表。 The members table is a 1 to 1 relationship with the users of my application. 成员表与我的应用程序的用户是一对一的关系。

But we can insert more members to our application in the members table than already created users for the application. 但是我们可以在成员表中向我们的应用程序中插入更多的成员,而不是已经为该应用程序创建的用户。

So we can have 100 users in our application. 因此,我们的应用程序中可以有100个用户。 And we can have 200 members in our members table. 我们的成员表中可以有200个成员。 Each user has a members row, but not each member is required to be a user. 每个用户都有一个成员行,但并非每个成员都必须是一个用户。

So, when the member finally claims their member row and signs up to the website, I need to be able to set the UserId (ProviderUserKey) when creating the new user for the site. 因此,当成员最终声明其成员行并注册该网站时,我需要能够在为该网站创建新用户时设置UserId(ProviderUserKey)。

So is it possible to change the providerkey when creating a new user account? 那么在创建新用户帐户时是否可以更改providerkey?

Thanks! 谢谢!

Are you using the default membership provider? 您是否使用默认的成员资格提供程序? I don't think you can if so. 我不认为可以。 It will create a unique key. 它将创建一个唯一的密钥。 You need to either create a custom provider and fix the code to include an ifUserExists method, create a user for every member and just assign them a limited role, or add a foreign key linking the two tables and let them each have non-matching IDs. 您需要创建一个自定义提供程序并修复代码以包括ifUserExists方法,为每个成员创建一个用户,然后为他们分配有限的角色,或者添加一个链接这两个表的外键并使它们各自具有不匹配的ID 。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM