要解决ASP.NET Core 3中出现的“没有为该方案注册的登录管理器”错误,您可以按照以下步骤进行操作:
services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme;
})
.AddCookie(options =>
{
options.LoginPath = "/Account/Login"; // 替换为您的登录路径
options.LogoutPath = "/Account/Logout"; // 替换为您的注销路径
});
app.UseAuthentication();
services.AddDefaultIdentity()
.AddEntityFrameworkStores(); // 替换为您的DbContext
netcoreapp3.0
这些步骤应该能够解决“没有为该方案注册的登录管理器”错误,并使您能够正确使用登录管理器。