ASP.NET Problem with emailSender in Register Page
Hi, so I did something and now when I go to my Register page (that I got when I create the project with the "Individual Accounts" authentication option), I get this exception:
InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Identity.UI.Services.IEmailSender' while attempting to activate 'Proj_Name.Areas.Identity.Pages.Account.RegisterModel'.
I've tried to try to comment ou any reference to emailSender in the entire solution, doing .AddDefaultUI() in my services config, here is that config code btw:
I should say that I don't have an actual emailSender implement nor desire or resources to implement it. I don't actually need to have email confirmation of accounts, I was happy with what it did before which was just show the text page pretending there was an email confirmation feature when there wasn't.7 Replies
looks like the
RegisterModel
is expecting IEmailSender
to be injected but you don't have an IEmailSender
in your service collectionyou need to register some implementation of it
it can be a dummy implementation that doesn't do anything if you don't actually want to send emails
or find the relevant configuration to disable email confirmation on registration
probably the better option considering a non-confirmed account probably isn't usable
The only thing I've found to disable email confirmation, is doing:
Which I've done and gotten the same exception.
WHat would you say would be the bare minimum to write a dummy implementation of emailSender?
if you created the project with authentication individual accounts (or whatever the option is) the identity defaults include a
IdentityNoOpEmailSender
what @Anu6is said, or just implement the interface methods and do nothing in them
this is provided default
@🅱immacle @Anu6is ok, thank ya'll I started moving stuff around and somehow I ended up changing compiler versions and it got real ugly real fast, just reverted to previous commit, will try again to implement what I was doing more carefully and with you guy's advice
I'll call you guys here if I run into more trouble with that