Search code examples
asp.net-mvcemailexceptionasp.net-identity

What to do when an exception is raised during send email for registration


I am doing a MVC5 application and I am using ASP.NET identity for authentication. When a user get registered, he must confirm his email address. So I send him an email where there is the link he must click. But, do I have to do if an exception is raised during the send email? The user is saved in the database, but ther user receive no email!

So I thought 2 solution:

  1. "Hide" the exception. The user is redirect to the page that inform him that an email has been sent. He does not receive any email so when he try to login can click on a link that send the email again.
  2. Fail the registration, so delete the user has been saved in the database.

In your experiences, what solution do you have adopted? one of mine? others? Can you help me to understand which is the best way to solve my problem?

Thnak you


Solution

  • I would go with 1)
    The user can still re-try for a confirmation email.

    A better approach, however;
    Send the email on a background task, using Hangfire - this has built in retries in case of failure.