locked
How to Resend confirmation email in Asp.Net C# RRS feed

  • Question

  • User-218090889 posted

    I have a method at Page_Load that will check if eMail has been confirmed in the aspNetUsers table, if eMail is not confirmed the method will resend the email for confirmation.
    Below is the code to resend the eMail.

    string user = eMailFromDatabase;
    var manager = Context.GetOwinContext().GetUserManager<ApplicationUserManager>(); string code = manager.GenerateEmailConfirmationToken(user); string callbackUrl = IdentityHelper.GetUserConfirmationRedirectUrl(code, user, Request); manager.SendEmail(user, "Confirm your account", "Thank you for registering on Our platform. Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>.");

    My issue is the when I tried to run the code it shows error message as below
    The method or operation is not implemented.

    What is it that is wrong with my code?

    Friday, January 22, 2021 2:37 PM

Answers

  • User-218090889 posted

    I have resolved the issue.

    I made the UserId to reflect the Id in my database. and it works.

    var manager = Context.GetOwinContext().GetUserManager<ApplicationUserManager>();
    string code = manager.GenerateEmailConfirmationToken(Id);
    string callbackUrl = IdentityHelper.GetUserConfirmationRedirectUrl(code, Id, Request);
    manager.SendEmail(Id, "Confirm your account", "Thank you for registering on Our platform. Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>.");

    var manager = Context.GetOwinContext().GetUserManager<ApplicationUserManager>();
    string code = manager.GenerateEmailConfirmationToken(user);
    string callbackUrl = IdentityHelper.GetUserConfirmationRedirectUrl(code, user, Request);
    manager.SendEmail(user, "Confirm your account", "Thank you for registering on Our platform. Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>.");

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, March 12, 2021 5:19 AM

All replies

  • User-821857111 posted

    My issue is the when I tried to run the code it shows error message as below
    The method or operation is not implemented.
    Which method does the error message refer to?

    Sunday, January 24, 2021 6:02 PM
  • User-218090889 posted

    Which method does the error message refer to?

    The stock below. Is the same I use when user register on my site, it sends confirmation eMail, and it is working very well, but I am tring to figure out how I can use it to re-send confirmation email to user.

    var manager = Context.GetOwinContext().GetUserManager<ApplicationUserManager>();
    string code = manager.GenerateEmailConfirmationToken(user);
    string callbackUrl = IdentityHelper.GetUserConfirmationRedirectUrl(code, user, Request);
    manager.SendEmail(user, "Confirm your account", "Thank you for registering on Our platform. Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>.");

    Thursday, January 28, 2021 5:19 AM
  • User-1330468790 posted

    Hi Enzyme,

     

    If you have already used the codes successfully, I think every method is configured correctly in the project.

    Could you please set up a bread point in that code line and check the 'manager' variable to see if it is of a correct type?

      

    Another suggestion is to set up OWIN Startup Class Detection for that Startup class.

    For example, add below configuration information in web.config file.

    <add key="owin:appStartup" value="[Namespace].Startup, [AssemblyName]" />

    Reference:

    https://docs.microsoft.com/en-us/aspnet/aspnet/overview/owin-and-katana/owin-startup-class-detection#owin-startup-class-detection-1

     

    Hope helps.

    Best regards,

    Sean

    Friday, January 29, 2021 7:55 AM
  • User-218090889 posted

    I have resolved the issue.

    I made the UserId to reflect the Id in my database. and it works.

    var manager = Context.GetOwinContext().GetUserManager<ApplicationUserManager>();
    string code = manager.GenerateEmailConfirmationToken(Id);
    string callbackUrl = IdentityHelper.GetUserConfirmationRedirectUrl(code, Id, Request);
    manager.SendEmail(Id, "Confirm your account", "Thank you for registering on Our platform. Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>.");

    var manager = Context.GetOwinContext().GetUserManager<ApplicationUserManager>();
    string code = manager.GenerateEmailConfirmationToken(user);
    string callbackUrl = IdentityHelper.GetUserConfirmationRedirectUrl(code, user, Request);
    manager.SendEmail(user, "Confirm your account", "Thank you for registering on Our platform. Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>.");

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, March 12, 2021 5:19 AM