使用Membership.CreateUser创建用户 [英] Create User using Membership.CreateUser

查看:133
本文介绍了使用Membership.CreateUser创建用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用下面的创建使用SqlMembershipProvider的新用户。虽然尝试使用新的CreateUserWizard用户创建,它抛出异常'用户名已被使用,即使是没有任何用户存在,也是新行,在我这个表的用户名和密码成功创建。

 的MembershipUser NEWUSER = Membership.CreateUser(createWizard.UserName,createWizard.Password);

如果我硬code的用户名和没有发生异常密码的值。

任何一个可以告诉我为什么使用CreateWizard时抛出异常的原因是什么?


解决方案

  MembershipCreateStatus状态;
VAR用户= Membership.CreateUser(登录名,密码,电子邮件,NULL,NULL,真正的,出状况);

试试这个。

I used the following to create new users using SqlMembershipProvider. While trying to create new users using CreateUserWizard, it throws exception 'The username is already in use' even though there is no any user exists and also new row is creating successfully with this username and password in my table.

MembershipUser newUser = Membership.CreateUser(createWizard.UserName, createWizard.Password);

If i hard code the value of username and password no exception occurs.

Can any one tell me the reason why it throws the exception when using CreateWizard?

解决方案

MembershipCreateStatus status;
var user = Membership.CreateUser(login, password, email, null, null, true, out status);

Try this.

这篇关于使用Membership.CreateUser创建用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆