سؤال

Identity 2.0 boasts new functionality in this area, but there's no documentation.

هل كانت مفيدة؟

المحلول 2

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

نصائح أخرى

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

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top