Beispiel #1
0
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                try
                {
                    fileHandler = new FileOperations();
                    fileHandler.AddUserFolder(model.UserName);
                    WebSecurity.CreateUserAndAccount(model.UserName, model.Password);
                    WebSecurity.Login(model.UserName, model.Password);
                    return(RedirectToAction("Index", "Home", new { user = model.UserName }));
                }
                catch (MembershipCreateUserException e)
                {
                    ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
                }
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Beispiel #2
0
 private ActionResult RedirectToLocal(string returnUrl, string userName)
 {
     fileHandler = new FileOperations();
     fileHandler.AddUserFolder(userName);
     return(RedirectToAction("Index", "Home", new { user = userName }));
 }