Registration and Email Verification for New Accounts
In This Code i am Providing the code by which the user can easily registered to the Website and the E-Mail is sent to the user for the Verification. If the user will not verify his/her email,the account is not activated and that person cannot login.
Here are the Following Steps to achieve that:-
1.Create new Web application and make one form in which the user can register and add the following code to the source code:
//Send email to user for verifying account
CreateUserWizard cuw = (CreateUserWizard)sender;
MembershipUser user = Membership.GetUser(cuw.UserName);
Guid userId = (Guid)user.ProviderUserKey;
System.Net.Mail.MailMessage EmailMsg = new System.Net.Mail.MailMessage("info@ask.com",
CreateUserWizard1.Email);
EmailMsg.Subject = "Email Verification fromhttp:dinesh-itsolutions.blogspot.com/";
EmailMsg.IsBodyHtml = true;
EmailMsg.Body = "Thanks for registering with www.http://dinesh-itsolutions.blogspot.com/!<br /><br />Your activation link : <a href=http://http://dinesh-itsolutions.blogspot.com/?ID=" + userId.ToString() + ">Link</a>.";
System.Net.Mail.SmtpClient mailClient = new System.Net.Mail.SmtpClient();
//This object stores the authentication values
System.Net.NetworkCredential basicAuthenticationInfo = new System.Net.NetworkCredential("smtpserverinfo", "smtpserverpassword");
mailClient.Host = "mail.ask.com";
mailClient.UseDefaultCredentials = false;
mailClient.Credentials = basicAuthenticationInfo;
mailClient.Send(EmailMsg);
2.By the code the email is sent to the user with the unique link.
3.When the user check his/her mail and click on the activate link then it will redirected to the new webpage
now retrieve that unique id from the URL.
4.After Retrieving the Id'...just set the stutus of the Client from 0 to 1 in the database so that the person can login.
Thank You:
Enjoy ....................n in case if any query then ask me......
Here are the Following Steps to achieve that:-
1.Create new Web application and make one form in which the user can register and add the following code to the source code:
//Send email to user for verifying account
CreateUserWizard cuw = (CreateUserWizard)sender;
MembershipUser user = Membership.GetUser(cuw.UserName);
Guid userId = (Guid)user.ProviderUserKey;
System.Net.Mail.MailMessage EmailMsg = new System.Net.Mail.MailMessage("info@ask.com",
CreateUserWizard1.Email);
EmailMsg.Subject = "Email Verification fromhttp:dinesh-itsolutions.blogspot.com/";
EmailMsg.IsBodyHtml = true;
EmailMsg.Body = "Thanks for registering with www.http://dinesh-itsolutions.blogspot.com/!<br /><br />Your activation link : <a href=http://http://dinesh-itsolutions.blogspot.com/?ID=" + userId.ToString() + ">Link</a>.";
System.Net.Mail.SmtpClient mailClient = new System.Net.Mail.SmtpClient();
//This object stores the authentication values
System.Net.NetworkCredential basicAuthenticationInfo = new System.Net.NetworkCredential("smtpserverinfo", "smtpserverpassword");
mailClient.Host = "mail.ask.com";
mailClient.UseDefaultCredentials = false;
mailClient.Credentials = basicAuthenticationInfo;
mailClient.Send(EmailMsg);
2.By the code the email is sent to the user with the unique link.
3.When the user check his/her mail and click on the activate link then it will redirected to the new webpage
now retrieve that unique id from the URL.
4.After Retrieving the Id'...just set the stutus of the Client from 0 to 1 in the database so that the person can login.
Thank You:
Enjoy ....................n in case if any query then ask me......
nice work..hey thanx for coding.
ReplyDeleteThis is a nice article..
ReplyDeleteIts easy to understand ..
And this article is using to learn something about it..
c#, dot.net, php tutorial, Ms sql server
Thanks a lot..!
ri70