我正在 Dot Net core MVC 7 中实现身份。这是我正在遵循的教程。然后突然错误来了错误来了
An unhandled exception occurred while processing the request.
InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Identity.UserManager`1[Microsoft.AspNetCore.Identity.IdentityUser]' while attempting to activate 'LearnIdentity.Areas.Identity.Pages.Account.RegisterModel'.
Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetService(IServiceProvider sp, Type type, Type requiredBy, bool isDefaultParameterRequired)
我尝试一次又一次地重新观看视频。尝试过聊天 GTP。无法解决请帮助我 点击这里查看源代码
单击登录按钮时,我下载了您的存储库并在我这边重现了该问题。
错误
然后我检查
Program.cs
文件和login.cshtml
文件login.cshtml.cs
。您正在使用ApplicationUser
inProgram.cs
并使用IdentityUser
inlogin.cshtml.cs
。解决方案是使用
ApplicationUser
在login.cshtml.cs
. 这个问题将会得到解决。并且请不要忘记using LearnIdentity.Data;
添加login.cshtml.cs
它在我身边起作用