我想使用Identity 2使用Visual Studio中的当前模板构建一个ASP.net Web API。使用Identity 2确认Web API 2中的电子邮件的最佳方式是什么?
我想确认创建帐户的电子邮件地址是否是有效的电子邮件地址。
我真的找不到很多如何使用当前模板进行指导。
我发现 http://bitoftech.net/2015/02/03/asp-net-identity-2-accounts-confirmation-password-user-policy-configuration/如果从头开始构建,但事情是非常混乱。我正在查看他的AccountController的注册操作代码。
string code = await this.AppUserManager.GenerateEmailConfirmationTokenAsync(user.Id);
var callbackUrl = new Uri(Url.Link("ConfirmEmailRoute", new { userId = user.Id, code = code }));
await this.AppUserManager.SendEmailAsync(user.Id,"Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");
Uri locationHeader = new Uri(Url.Link("GetUserById", new { id = user.Id }));
return Created(locationHeader, TheModelFactory.Create(user));
我当前的代码是:
// For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
// Send an email with this link
string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
code = HttpUtility.UrlEncode(code);
var callbackUrl = new Uri(Url.Link("ConfirmEmailRoute", new { userId = user.Id, code = code }));
await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");
Uri locationHeader = new Uri(Url.Link("GetUserById", new { id = user.Id }));
return Created(locationHeader,);
他TheModelFacory.Create我找不到任何地方。我能够找到他为他的项目创建的BaseApiController : ApiController
中提到的TheModelFactory,但不能在我的生活中找出它适合当前具有个人用户帐户模板的Web Api的地方。
作为T Content
而不是TheModelFactory.Create(user)
为了让它起作用,我该怎么做?