✅ unregistered services
I am implementing my own version of MapIdentityAPI<>() to add some custom functionality. to do this I've copied the code for the method and dependencies out of Microsoft.AspNetCore.Routing into a separate class from where i can call this CustomMapIdentityAPI<>().
i have finally purged all the errors and I've gotten to testing, but now i am getting this error:
pointing at this line:
I've tried reverting to the old version of MapIdentityApi<>() but i get the same error, so i assume its not something I've changed on accident. This leads me to conclude that my set up is flawed. i did just change my Main to be
async Task<int> Main
instead of int Main
, is this it? if so, how do i seed my roles without async methods?17 Replies
heres my set up code:
:/
probubly figured it out
To my understanding your problem is currently that nothing is registering an implementation of IEmailSender.
builder.Services.someStuff
I think you need to write and register an implementation of IEmailSender
for posterity,
registering a service is using
builder.Services.ReliventRegistrationMethod()
like builder.Services.AddIdentity
or builder.Services.AddControllersWithViews()
already on it. found right documentation
thanks👍 Good luck
the bigest question is why it worked in the first place :)
i had this working for hours without an email service registered
um...
Something probably registers an implementation of IEmailSender when using
.MapIdentityAPI
shouldent this work??
my current implimentation of that method is litarly coppied and pasted.
Should work yes.
need to get it to work before i can change it
so beans
now it complanes that it has been registered???
Unhandled exception. System.InvalidOperationException: No service for type 'Microsoft.AspNetCore.Identity.IEmailSender'1[Microsoft.AspNetCore.Identity.IdentityUser]' has been registered.
That's the same error as you got before
yea... but now ive registed it... weird
aaand now my it dosent like my EmailServices class...
man computers can be weird.
Think it's because you're not implementing the generic IMailSender<TUser> class
Think this is as far as my knowledge goes tbh, hope someone else has a concrete answer 😭
so
emailServices : IMailSender
?Yes
Don't write your own IEmailSender
Try just inheriting from the
Microsoft.AspNetCore.Identity.IEmailSender
ok. the exact service asked for is
IEmailSender<TUser>
but when i add <TUser>
to the the extention declaration it freaks out.