Tutorialsconcerningasp.netIdentitysuchasusermanagement,rolemanagement,creatingtokensandmore.
Section 151.1: How to implement password reset token in asp.netidentityusingusermanager
- CreateanewfoldercalledMyClassesandcreateandaddthefollowingclass
publicclassGmailEmailService:SmtpClient
{
//Gmailuser-name
publicstringUserName{get;set;}
publicGmailEmailService():
base(ConfigurationManager.AppSettings[“GmailHost”],
Int32.Parse(ConfigurationManager.AppSettings[“GmailPort”]))
{
//Getvaluesfromweb.configfile:
this.UserName=ConfigurationManager.AppSettings[“GmailUserName”]; this.EnableSsl=Boolean.Parse(ConfigurationManager.AppSettings[“GmailSsl”]); this.UseDefaultCredentials=false;
this.Credentials=newSystem.Net.NetworkCredential(this.UserName, ConfigurationManager.AppSettings[“GmailPassword”]);
}
}
2. ConfigureyourIdentityClass
publicasyncTaskSendAsync(IdentityMessagemessage)
{
MailMessageemail=newMailMessage(newMailAddress(“youremailadress@domain.com”,”(any subjecthere)”),
newMailAddress(message.Destination));
email.Subject=message.Subject;
email.Body=message.Body;
email.IsBodyHtml=true;
GmailEmailServicemailClient=newGmailEmailService();
awaitmailClient.SendMailAsync(email);
}
3. Add your credentials to the web.config. I did not use gmail in this portion because the use of gmail is blocked in my workplace and it still works perfectly.
lt;add key=”GmailUserName”value=”youremail@yourdomain.com”/><add key=”GmailPassword” value=”yourPassword”/><add key=”GmailHost” value=”yourServer”/><add key=”GmailPort”value=”yourPort”/><add key=”GmailSsl” value=”chooseTrueOrFalse”/><!–Smptp Server (confirmations emails)–>
4. MakenecessarychangestoyourAccountController.Addthefollowinghighlightedcode.
![](https://i0.wp.com/venturesoftwares.in/wp-content/uploads/image-126.png?resize=470%2C529&ssl=1)
![](https://i0.wp.com/venturesoftwares.in/wp-content/uploads/image-127.png?resize=772%2C459&ssl=1)
Compilethenrun.Cheers!
About us and this blog
We are a digital marketing company with a focus on helping our customers achieve great results across several key areas.
Request a free quote
We offer professional SEO services that help websites increase their organic search score drastically in order to compete for the highest rankings even when it comes to highly competitive keywords.
Subscribe to our newsletter!
More from our blog
See all postsRecent Posts
- Chapter161:ImportGoogleContacts 30/06/2024
- Chapter160:IncludingFontResources 29/06/2024
- Chapter159:CreatingOwnMessageBoxin WindowsFormApplication 28/06/2024