Membership.GetAllUsers() 给出错误“项目已被添加”
我正在使用会员提供商,现在面临以下错误:
System.ArgumentException:项目已添加。字典中的键:“0859929000”正在添加的键:“0859929000”
该键是 aspnet_Users 表中的用户名,该表没有重复项。
此代码生成错误:
private void BindUsersToUserList()
{
// Get all of the user accounts
MembershipUserCollection users = Membership.GetAllUsers();
UserList.DataSource = users;
UserList.DataBind();
}
所有用户均由我使用存储过程 aspnet_Users_CreateUser
和 aspnet_Membership_CreateUser
手动导入。
现在的问题是,问题出在哪里? 数据库中是否有其他地方可能出现重复(表、损坏的索引等)并导致此问题?
I'am using the Membership provider and now facing the following error:
System.ArgumentException: Item has already been added. Key in dictionary: '0859929000' Key being added: '0859929000'
The Key is the UserName from the aspnet_Users table, which has no duplicates.
This code generates the error:
private void BindUsersToUserList()
{
// Get all of the user accounts
MembershipUserCollection users = Membership.GetAllUsers();
UserList.DataSource = users;
UserList.DataBind();
}
All users are imported manually by me using the stored procedures aspnet_Users_CreateUser
and aspnet_Membership_CreateUser
.
Now, the question is, where is the problem?
Is there anywhere else in the database duplicates might occur (tables, corrupt indexes etc.) and cause this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题解决了。
LoweredUserName 列中有重复项。我不知何故错过了这一点。
Problem solved.
There were duplicates in the LoweredUserName column. I missed that somehow.