Using ASP.Net Core, the sample didn't work, with SigninManager
See original GitHub issueI am using the IdentityCore like following:
services.AddIdentityCore<ApplicationUser>()
.AddUserStore()
.AddSignInManager()
.AddDefaultTokenProviders();
When I use the following code with it:
services
.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(CookieAuthenticationDefaults.AuthenticationScheme);
services.AddSingleton<IMultiTenantStore>((serviceProvider) =>
{
var cfg = serviceProvider.GetService<List<TenantConfiguration>>();
return new TenantResolver(cfg.ToArray());
});
services.AddMultiTenant()
.WithHostStrategy()
.AddPerTenantCookieAuthentication();
public static MultiTenantBuilder AddPerTenantCookieAuthentication(this MultiTenantBuilder builder)
{
return builder.WithPerTenantOptions<CookieAuthenticationOptions>((options, tenantContext) =>
{
// Set a unique cookie name for this tenant.
options.Cookie.Name = tenantContext.Id + "-cookie";
});
}
I get the following error: InvalidOperationException: No sign-in authentication handler is registered for the scheme ‘Identity.Application’. The registered sign-in schemes are: cookies. Did you forget to call AddAuthentication().AddCookies(“Identity.Application”,…)?
Microsoft.AspNetCore.Authentication.AuthenticationService.SignInAsync(HttpContext context, string scheme, ClaimsPrincipal principal, AuthenticationProperties properties)
Microsoft.AspNetCore.Identity.SignInManager<TUser>.SignInAsync(TUser user, AuthenticationProperties authenticationProperties, string authenticationMethod)
Profile.Controllers.AccountController.Registreer(RegisterViewModel model, string returnUrl) in AccountController.cs
await signInManager.SignInAsync(user, isPersistent: false);
If I change the scheme to this:
services
.AddAuthentication("Identity.Application")
.AddCookie("Identity.Application");
I can log in. Am I configuring something wrong? I would rather not hard code this value, to this one value I can’t change.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
SignInManager dependency injection fails with ASP.NET ...
If I remove the SignInManager parameter from the constructor everything works fine. All the relevant examples I have seen online end up being ......
Read more >SignInManager not working when injected to razor page
Hi, i'm having troubles getting SignInManager injected in a razor page , the signInManager.IsSignedIn(User) is alway false even if i'm loged ...
Read more >Extending the ASP.NET Core 1.0 Identity SignInManager
In this post I show how we can extend and override the default behaviour of the ASP.NET Core 1.0 Identity SignInManager class to...
Read more >ASP NET Core Identity UserManager and SignInManager
We use the generic parameter to specify the User class that these services should work with. At the moment, we are using the...
Read more >Custom User Management in ASP.NET Core MVC ...
We will build a small yet practical implementation of Custom User Management in ASP.NET Core MVC with Identity. This will cover most of...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ok, it is is SignInManager (https://github.com/aspnet/Identity/blob/c7276ce2f76312ddd7fccad6e399da96b9f6fae1/src/Identity/SignInManager.cs#L194)
So basically if you want to use the SigninManager you will need to use scheme:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.