0

The code to register a user works locally against the production DB, but for some reason, on the remote host, the user isn't added and the Register view is being returned (the delivered Register view, not the one I'm using). It doesn't appear that any errors are being issued, as I've tried to return Content any result errors from the UserManager.CreateAsync task. I'll post my code below, but I don't know if it will help. What could be keeping it from working on the remote host vs. working correctly when executed locally?

public async Task<ActionResult> Register(RegisterViewModel model)
    {
        if (ModelState.IsValid)
        {
            var user = new ApplicationUser { UserName = model.Email, Email = model.Email };

            var result = await UserManager.CreateAsync(user, model.Password);
            if (result.Succeeded)
            {
                //await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);
                var identity = new IdentityManager();

                if (!identity.RoleExists("profile"))
                {
                    identity.CreateRole("profile");
                }
                bool userAdded = identity.AddUserToRole(user.Id, "profile");

                string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                await UserManager.SendEmailAsync(user.Id,
                        "Confirm your account for Site",
                        "Please confirm your account by clicking this link: <a href=\""
                        + callbackUrl + "\">link</a>");
                return View("ConfirmationEmailSent");
            }
            AddErrors(result);
        }

        // If we got this far, something failed, redisplay form
        return View("Login", model);
    }
jallen
  • 602
  • 12
  • 32

1 Answers1

0

Okay, it's due to the host's add trailing slash rule. It must be clashing with how I configured routing.

jallen
  • 602
  • 12
  • 32