Search code examples
c#asp.netemail-verification

Asp.net Verification Email


After the user finishes registration process, we need to send verification email to the user. I know how to send email but i need to know what is the process of sending a verification link, should i create a column in the table to save the verification token and send it encrypted. If we have to save the verification token what is the perfect way to generate this token. I do not try any solution.


Solution

  • Yes, you should create a column in the table to save the verification token.

    You can have activation code as "GUID"

    A simple way of do the same is:

    1. Build your Query String by combining User-ID, verification token and Creation-date.

    2. Do encoding of the combined string

      "?user=" + Convert.ToBase64String(Encoding.Unicode.GetBytes(String.Format("user={0}&code={1}&cd={2}", User-ID, verification, Creation-date)));

    3. Send the link to the user

    4. When your user clicks on the link, decode the Query String

    5. Separate the combined values by spiting it using "&"

      Encoding.Unicode.GetString(Convert.FromBase64String(ActivationDetails)).Split(new Char[] { '&' });

    You have all values required to activate the account. Also, you can add your logic and encryption methods. However, the base remains same.

    Hope this helps.