asp.net mvc 3 - Background Registration MVC3 -
working on mvc4 application users first fill in form starting point. form there field provide user email , unique 9 digit number , other details. want achieve after submitting form want user silently registered using unique 9 digit number username, , auto-generated password hashed , saved password in membership(extended simplemembership) database. email password sent user afterwards. grateful hints or in regards.
after form filled, make following redirection
return redirecttoaction("autoregister", new routevaluedictionary(new { controller = "account", action = "autoregister", uname= viewbag.uname, uemail = viewbag.uemail }));
and have following code in account controller
[allowanonymous] public actionresult autoregister() { return view(); } [allowanonymous] [httppost] public actionresult autoregister(registermodel model,string uname, string uemail) { //if (modelstate.isvalid) if(uemail!=null && uname!=null) { string upass = membership.generatepassword(12, 1); model.email = uemail; model.username = uname; model.password = upass; // attempt register user membershipcreatestatus createstatus; membership.createuser(model.username, model.password, model.email, passwordquestion: null, passwordanswer: null, isapproved: false, provideruserkey: null, status: out createstatus); if (createstatus == membershipcreatestatus.success) { formsauthentication.setauthcookie(model.username, createpersistentcookie: false); return redirecttoaction("welcome", "onlineapplication"); } else { modelstate.addmodelerror("", errorcodetostring(createstatus)); } }
i have set routeconfig
accept url. when fill form redirects allright page url parameters populated nothing happens. user not created. emailing of password can fix no problems.
assist on how can commit new user details in database
Comments
Post a Comment