You must Sign In to post a response.
  • Category: ASP.Net MVC

    Unable to send mail using form based authentication

    i am unable to send mail using below code when call await UserManager.SendEmailAsync()

    public async Task<ActionResult> ForgotPassword(ForgotPasswordViewModel model)
    if (ModelState.IsValid)
    var user = await UserManager.FindByNameAsync(model.Email);
    // Don't check confirmation status for now
    //if (user == null || !(await UserManager.IsEmailConfirmedAsync(user.Id)))
    if (user == null)
    ModelState.AddModelError("", "The user either does not exist or is not confirmed.");
    return View();

    // For more information on how to enable account confirmation and password reset please visit
    // Send an email with this link
    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>");
    catch (Exception ex)
    ModelState.AddModelError("", ex.Message);
    return View(model);
    return RedirectToAction("ForgotPasswordConfirmation", "Account");

    // If we got this far, something failed, redisplay form
    return View(model);

    provide some code to send mail when call await UserManager.SendEmailAsync()
  • #762259
    Hello Sandip,

    You can go through the below links for your reference :

    Hope this will work for you.

    Nirav Lalan
    DNS Gold Member
    "Failure is the path of least persistence"

Sign In to post your comments