Creating a new user using System.Web.Providers within ASP.NET MVC4 -
i've been able phone call membership.createuser
has created necessary membership tables within database, hasn't added newly created user users
table , membershipcreatestatus = invalidanswer
- not sure means.
public void register(register register) { var fellow member = new system.web.providers.defaultmembershipprovider(); object guid = guid.newguid(); membershipcreatestatus status; member.createuser(register.username, register.password, "", "", "", true, guid, out status); }
configuration:
<profile defaultprovider="defaultprofileprovider"> <providers> <add name="defaultprofileprovider" type="system.web.providers.defaultprofileprovider, system.web.providers, version=1.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" connectionstringname="defaultconnection" applicationname="/" /> </providers> </profile> <membership defaultprovider="defaultmembershipprovider"> <providers> <add name="defaultmembershipprovider" type="system.web.providers.defaultmembershipprovider, system.web.providers, version=1.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" connectionstringname="defaultconnection" enablepasswordretrieval="false" enablepasswordreset="true" requiresquestionandanswer="false" requiresuniqueemail="false" maxinvalidpasswordattempts="5" minrequiredpasswordlength="6" minrequirednonalphanumericcharacters="0" passwordattemptwindow="10" applicationname="/" /> </providers> </membership> <rolemanager defaultprovider="defaultroleprovider"> <providers> <add name="defaultroleprovider" type="system.web.providers.defaultroleprovider, system.web.providers, version=1.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" connectionstringname="defaultconnection" applicationname="/" /> </providers> </rolemanager>
the reply here based on our discussion.
i assume have specified in web.config
enablepasswordretrieval="false"
comment
then code work you
try { object guid = guid.newguid(); membershipcreatestatus status; membershipuser fellow member = membership.createuser(register.username, register.password, "an email address here", null, null, true, guid, out status); } catch(membershipcreateuserexception ex) { //handle exceptions }
asp.net-mvc-4 system.web createuser
No comments:
Post a Comment