I have an MVC 5 project that has been modified to use int as the primary key for identity as shown in this guide
I then enabled email confirmation as described in this guide
Everything worked fine as expected. Then I installed structuremap.mvc5 for dependency injection and added modified DefaultRegistry.cs to
public DefaultRegistry() {
Scan(
scan => {
scan.TheCallingAssembly();
scan.WithDefaultConventions();
scan.AssemblyContainingType(typeof(MyProject.Data.MyDbContext));
scan.With(new ControllerConvention());
});
//For<IExample>().Use<Example>();
For<IUserStore<ApplicationUser, int>>().Use<MyUserStore>().LifecycleIs<HttpContextLifecycle>();
For<IAuthenticationManager>().Use(() => HttpContext.Current.GetOwinContext().Authentication);
}
The project builds fine but when trying to register a new user on the site, the send email confirmation now throws an exception System.NotSupportedException: No IUserTokenProvider is registered when calling UserManager.GenerateEmailConfirmationTokenAsync(userID).
private async Task<string> SendEmailConfirmationTokenAsync(int userID, string subject)
{
string code = await UserManager.GenerateEmailConfirmationTokenAsync(userID);
var callbackUrl = Url.Action("ConfirmEmail", "Account",
new { userId = userID, code = code }, protocol: Request.Url.Scheme);
await UserManager.SendEmailAsync(userID, subject,
"Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");
return callbackUrl;
}
I am new to dependency injection and pretty sure I am doing something wrong. I'll appreciate your thoughts and insights.