Install the Microsoft.AspNet.Identity.Samples package on an empty project and you can find the code that implements the functionality. The sample application is written in MVC
How do you use the Confirm Email functionality in ASP.NET Identity 2.0
-
07-07-2023 - |
سؤال
Identity 2.0 boasts new functionality in this area, but there's no documentation.
المحلول 2
نصائح أخرى
New article posted here. Adds new information. http://www.asp.net/identity/overview/features-api/account-confirmation-and-password-recovery-with-aspnet-identity
I found a couple of scraps of sample code. They were sufficiently obscure that I decided this posting would be useful. This is how you generate a code and a callback 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>.");
This is how you handle it on the return:
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);
.... References: https://aspnet.codeplex.com/SourceControl/latest#Samples/Identity/Webforms.Samples/Webforms.Samples/Account/Confirm.aspx.cs
لا تنتمي إلى StackOverflow