Log Users in after registration and posting with Ajax RRS feed

  • Question

  • User-1861000632 posted

    Hi Guys,

    How can I automatically sign a User in after registering. I am posting the registration with Ajax because I'm adding more fields to the register view model and on the response, I want to sign the just registered user in.

    Friday, February 1, 2019 5:26 PM


  • User1724605321 posted

    Hi Samseen ,

    You should provide more details ,  are you using something like ASP.NET Membership Provider  /ASP.NET Identity to authenticate or are you writing your own custom authentication  layer? 

    If you are using MVC & Asp.net Identity , i would suggest modify the `Register.cshtml` to include more fields and also `RegisterViewModel` , after user register his account , he will be login by default :

     if (result.Succeeded)
                        await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false);
                        // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                        // Send an email with this link
                        // 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", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");
                        return RedirectToAction("Index", "Home");

    Best Regards,

    Nan Yu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, February 4, 2019 2:07 AM