C# 不为类型'提供服务;Microsoft.AspNetCore.Identity.UserManager`1[SolutionName.Areas.Identity.Data.SolutionNameUser]';已注册
当我添加EmailSender用于密码恢复和电子邮件确认时,我在启动时收到了这条消息。在我添加指南中的所有内容之前,我已经检查了tripple是否正确地完成了指南中的所有内容,并且(从我看到的情况来看)应用程序正常工作。我以前在另一个应用程序上做过,没有任何问题,所以我觉得我现在被卡住了 我用的是刮胡刀 Startup.cs中的My ConfigureServices:C# 不为类型'提供服务;Microsoft.AspNetCore.Identity.UserManager`1[SolutionName.Areas.Identity.Data.SolutionNameUser]';已注册,c#,asp.net-mvc,asp.net-identity,C#,Asp.net Mvc,Asp.net Identity,当我添加EmailSender用于密码恢复和电子邮件确认时,我在启动时收到了这条消息。在我添加指南中的所有内容之前,我已经检查了tripple是否正确地完成了指南中的所有内容,并且(从我看到的情况来看)应用程序正常工作。我以前在另一个应用程序上做过,没有任何问题,所以我觉得我现在被卡住了 我用的是刮胡刀 Startup.cs中的My ConfigureServices: public void ConfigureServices(IServiceCollection services) {
public void ConfigureServices(IServiceCollection services)
{
services.Configure<CookiePolicyOptions>(options =>
{
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
options.CheckConsentNeeded = context => true;
options.MinimumSameSitePolicy = SameSiteMode.None;
});
services.AddAuthentication()
.AddFacebook(facebookOptions =>
{
facebookOptions.AppId = Configuration["Authentication:Facebook:AppId"];
facebookOptions.AppSecret = Configuration["Authentication:Facebook:AppSecret"];
})
.AddGoogle(googleOptions =>
{
googleOptions.ClientId = Configuration["Authentication:Google:ClientId"];
googleOptions.ClientSecret = Configuration["Authentication:Google:ClientSecret"];
});
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
services.AddSingleton<IEmailSender, EmailSender>();
services.Configure<AuthMessageSenderOptions>(Configuration);
}
public void配置服务(IServiceCollection服务)
{
配置(选项=>
{
//此lambda确定给定请求是否需要非必要cookie的用户同意。
options.checkApprovered=context=>true;
options.MinimumSameSitePolicy=SameSiteMode.None;
});
services.AddAuthentication()
.AddFacebook(facebook选项=>
{
facebookOptions.AppId=Configuration[“Authentication:Facebook:AppId”];
facebookOptions.AppSecret=配置[“身份验证:Facebook:AppSecret”];
})
.AddGoogle(谷歌选项=>
{
googleOptions.ClientId=Configuration[“Authentication:Google:ClientId”];
googleOptions.ClientSecret=Configuration[“Authentication:Google:ClientSecret”];
});
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
services.AddSingleton();
服务。配置(配置);
}
啊,是不是我缺少了“services.AddIdentity()”?。是的,我只是按照指南做的,他们就是这么做的。当我补充说我得到了“InvalidOperationException:Scheme已经存在:Identity.Application”