Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi im reseting users password using a url token in mvc,im able to send the email but whe i want to click the link and get redirected to resetpassword page it loads but dsnt show

here is my code for creeating the token and sending it

C#
public async Task<ActionResult> ForgotPassword(ForgotPasswordViewModel model)
        {
            //SendSmsBusiness objap = new SendSmsBusiness();
            RegisterBusiness reg = new RegisterBusiness();
            EmailBusiness _emailBusiness = new EmailBusiness();
            if (ModelState.IsValid)
            {
                
                ApplicationUser user = new ApplicationUser();
                user = reg.UserManager.FindByEmail(model.Email);

                // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                // Send an email with this link
                if (user != null)
                {
                    string code = await UserManager.GeneratePasswordResetTokenAsync(user.Id);
                    var callbackUrl = Url.Action("ResetPassword", "Account", new { userId = user.Id, code = code }, protocol:Request.Url.Scheme);
                    await UserManager.SendEmailAsync(user.Id, "Reset Password", "Please reset your password by clicking <a href=\"" + callbackUrl + "\">here</a>");
                    _emailBusiness.SendEmailForgot(model.Email, callbackUrl);
                    return RedirectToAction("ForgotPasswordConfirmation", "Account");
                }

                {
                    ModelState.AddModelError("", "The user does not exist");
                    return View();
                }
            }
            // If we got this far, something failed, redisplay form
            return View(model);
        }


my code seems fine but it doesnt give me the results im thinking its something to do with the protocol:request.url.scheme because when i hove over it it shows possible null exception

pls help im puzzled here

here is the
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900