Chapter151:ASP.NETIdentity

No Comments

Tutorialsconcerningasp.netIdentitysuchasusermanagement,rolemanagement,creatingtokensandmore.

Section 151.1: How to implement password reset token in asp.netidentityusingusermanager

  1. 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.

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 posts
No Comments

Leave a Comment