2014-04-23 126 views

回答

2

在一个空的项目上安装Microsoft.AspNet.Identity.Samples包,你可以找到th e代码实现了功能。示例应用程序是用MVC编写的

0

我发现了几个样本代码。他们足够模糊,我决定这个帖子是有用的。这是你如何生成代码和回调URL:

string code = manager.GenerateEmailConfirmationToken(user.Id); 
string callbackUrl = IdentityHelper.GetUserConfirmationRedirectUrl(code, user.Id); 
manager.SendEmail(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>."); 

这是你如何处理它的回报:

string code = IdentityHelper.GetCodeFromRequest(Request); 
string userId = IdentityHelper.GetUserIdFromRequest(Request); 
if (code != null && userId != null) 
     { 
      var manager = Context.GetOwinContext().GetUserManager<ApplicationUserManager>(); 
      var result = manager.ConfirmEmail(userId, code); 

.... 参考文献: https://aspnet.codeplex.com/SourceControl/latest#Samples/Identity/Webforms.Samples/Webforms.Samples/Account/Confirm.aspx.cs

https://aspnet.codeplex.com/SourceControl/latest#Samples/Identity/Webforms.Samples/Webforms.Samples/Account/Register.aspx.cs

相关问题